1

I run this command in my project folder

    npm install --global webpack webpack-dev-server

it return:

   /usr/lib

     ├── [email protected]
     └── [email protected]

webpack and webpack-dev-server folders are under /usr/lib/node_modules, webpack command works, webpack-dev-server command return:

 webpack-dev-server: command not found

the configure json:

  "webpack": "^1.14.0",
  "webpack-dev-server": "^1.9.0" 

I also tried install in without -g, there is node_modules under the project folder, and .bin folder under node_modules. However webpack-dev-server is out of node_modules folder. I try move webpack-dev-server into .bin. it does not work either.

1
  • I found an alternative way to make it work: run npm and webpack from the host machine. Commented Jan 12, 2017 at 5:50

2 Answers 2

1

Try this:

npm install webpack-dev-server -g

From this answer: https://stackoverflow.com/a/31627310

Sign up to request clarification or add additional context in comments.

Comments

0

installing packages globally is not good. Package.json does not define globally installed modules. When you run npm install command to setup a project, your project will not know about global modules.

You should install

npm i webpack-dev-server --save

then you need to add configuration into the webpack.config.js file. this is the related line for webpack-dev-server inside the file

 const path=require ("path")

{
    devServer: { contentBase: path.join(__dirname, "public") }

}

now you need to write this script on to package.json

"scripts":{    "dev-server": "webpack-dev-server",
}

this command will run your app

npm run dev-server

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.