Webpack - webpack-dev-server: command not found

后端 未结 11 1910
一个人的身影
一个人的身影 2020-12-22 23:29

I am working on a React webapp using webpack, loosely alongside this tutorial.

Accidentally, I added the node_modules folder to my git. I then removed it again using

相关标签:
11条回答
  • 2020-12-23 00:00

    For global installation : npm install webpack-dev-server -g

    For local installation npm install --save-dev webpack

    When you refer webpack in package.json file, it tries to look it in location node_modules\.bin\

    After local installation, file wbpack will get created in location: \node_modules\.bin\webpack

    0 讨论(0)
  • 2020-12-23 00:01

    npm install webpack-dev-server -g -- windows OS

    Better you use sudo in linux to avoid permission errors

    sudo npm install webpack-dev-server -g

    You could use sudo npm install webpack-dev-server --save to add it to package.json.

    Sometimes you may require to run the below commands.

    npm install webpack-cli --save or npm install webpack-cli -g

    0 讨论(0)
  • 2020-12-23 00:03

    The script webpack-dev-server is already installed inside ./node_modules directory. You can either install it again globally by

    sudo npm install -g webpack-dev-server
    

    or run it like this

    ./node_modules/webpack-dev-server/bin/webpack-dev-server.js -d --config webpack.dev.config.js --content-base public/ --progress --colors
    

    . means look it in current directory.

    0 讨论(0)
  • 2020-12-23 00:07

    Yarn

    I had the problem when running: yarn start

    It was fixed with running first: yarn install

    0 讨论(0)
  • 2020-12-23 00:07

    I had similar problem with Yarn, none of above worked for me, so I simply removed ./node_modules and run yarn install and problem gone.

    0 讨论(0)
提交回复
热议问题