Webpack-dev-server errors with "command not found: webpack-dev-server"

I donโ€™t understand why I canโ€™t get this to work ... I did the following.

npm install -g webpack webpack-dev-server 

Confirmed that both are installed successfully.

Now when I try to 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 normally, both locally and globally. I also tried installing it locally in the project (adding to package.json, npm install, yadda yadda ..) and getting the same error.

Did I miss something?

+5
source share
2 answers

Found a solution for this answer on GitHub :

I was able to solve this problem on my machine. Apparently this was a permissions issue.

I installed webpack and webpack-dev-server globally. However, even then $ webpack-dev-server led to the fact that the command was not found (as indicated above).

The problem was that npm installed global packages in /usr/local/lib/node_modules that required root privileges.

To avoid using root privileges, I changed the directory in which global packages should be installed in the directory in $HOME . For this, I followed this guide: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md

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

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

+4
source

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

+2
source

Source: https://habr.com/ru/post/1236084/


All Articles