• 本地安装并运行http-server、browser-sync、webpack


    有一些自带命令的辅助开发、测试类的工具,官方都推荐全局安装,如果不想全局安装只想在某个项目下用该怎么办呢? 如http-server、browser-sync、webpack这种自带CLI的工具 使用命令运行会报错,如下,

    $ http-server
    bash: http-server: command not found
    
    $ browser-sync
    bash: browser-sync: command not found
    
    $ webpack
    bash: webpack: command not found
    
    

    上面提示我们找不到这个命令
    解决1:直接使用下面方式运行

    $ ./node_modules/.bin/http-server -c-1 -o
    
    $ ./node_modules/.bin/browser-sync start --server --files "*"
    
    $ ./node_modules/.bin/webpack
    



    解决2:在 package.json里面的"scripts"对象里面添加 ``` "scripts": { "xxx": "http-server", "xxx": "browser-sync start --server --files "*"", "xxx": "webpack" } ``` ``` npm run xxx ```


    解决3:在 package.json里面的"scripts"对象里面添加 ``` "scripts": { "start": "http-server", "start": "browser-sync start --server --files "*"", "start": "webpack" } ``` ``` npm start ```
  • 相关阅读:
    Merge Intervals
    Merge k Sorted Lists
    Sqrt(x)
    First Missing Positive
    Construct Binary Tree from Inorder and Postorder Traversal
    Construct Binary Tree from Preorder and Inorder Traversal
    Distinct Subsequences
    Reverse Nodes in k-Group
    Jump Game II
    Jump Game
  • 原文地址:https://www.cnblogs.com/liu-di/p/10557786.html
Copyright © 2020-2023  润新知