6

don't really see why I can't get this to run... I've done the following.

npm install -g webpack webpack-dev-server

confirmed that both installed successfully.

Now, when I try and execute webpack-dev-server, I get the following:

$ webpack-dev-server --inline --hot
zsh: command not found: 'webpack-dev-server'

Never run into this as all my other npm modules load/run fine, both locally and globally. I've tried installing it locally to a project as well (adding to package.json, npm install, yadda yadda..) and receive the same error.

Am I missing something?

4
  • Same thing happening to me right now on Ubuntu. It worked on Mac a few hours ago.... Commented Nov 16, 2015 at 23:49
  • @jmacedo weird! Glad to know it's not just user error. Maybe they pushed a broken update shrug anyone else have any input? Commented Nov 17, 2015 at 15:50
  • any solution for the problem? Commented Jan 11, 2016 at 22:37
  • @IliyaReyzis yes! please see accepted answer, a solution was found. :) Commented Apr 1, 2016 at 18:12

2 Answers 2

4

Found a solution as per this answer on GitHub:

I was able to solve this problem on my machine. It appears to have been an issue with permissions.

I installed webpack and webpack-dev-server globally. However, even then, $ webpack-dev-server resulted in command not found (as stated above).

The problem was that npm installed the global packages to /usr/local/lib/node_modules which required root permissions.

In order to avoid having to use root permissions, I changed the directory in which global packages are to be installed to a directory in $HOME. To do this, I followed this guide: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md

I installed webpack and webpack-dev-server globally again (this time without sudo) and verified that they have been installed in my new directory.

Now, I can finally run $ webpack-dev-server.

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

Comments

3

The problem is that npm installs the global packages to /usr/local/lib/node_modules which requires root permissions. To avoid this you can use Use sudo npm i -g webpack webpack-dev-server.
It worked for me.

1 Comment

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.

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.