Webpack-dev-server: errors with "Command not found" on OSX, Ubuntu

Created on 17 Nov 2015  路  9Comments  路  Source: webpack/webpack-dev-server

Hey there,

Not sure what's up since I've run webpack-dev-server in the past just fine, but currently when I try and invoke it ( either globally or locally in a project ), I'm getting the following shell error:

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

I've tried:
A) uninstalling ( both locally and globally )
B) clearing NPM cache
C) re-installing ( both locally and globally )

but still receive the same error.

Further, I posted this originally as a question on StackOverflow, to which another user replied that they were encountering the exact same issue on Ubuntu.

Was a broken update recently pushed?

Most helpful comment

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.

I hope this helps @tconroy!

All 9 comments

I'm experiencing the same on Ubuntu (using vagrant with Windows host and Ubuntu guest).

I suspected node-gyp to be the problem, because of several error messages I received earlier. However, thanks to #302, which was merged tonight, socket.io was replaced. socket.io required node-gyp. So this shouldn't be a problem any longer.

Uninstalling and reinstalling everything (including the newest version of webpack-dev-server) still results in command not found when I run $ webpack-dev-server.

Any ideas how to fix this?

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.

I hope this helps @tconroy!

thanks man!

Thanks for sharing your findings @flindenberg! I'll try this when I get home tonight.

You're welcome! Good luck :-)

I had the same issue using nvm on ubuntu. Just in case anyone else runs into this.

sudo cp /home/[user]/.nvm/versions/node/[node_version]/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js /usr/local/bin/webpack-dev-server
chown [user]:[user] /usr/local/bin/webpack-dev-server
chmod +x /usr/local/bin/webpack-dev-server

Replace the content in brackets with your specific path info for user and node version.

thanks man! @flindenberg

Thanks man ! It helped

Bro, Thank youuu :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrdulin picture mrdulin  路  3Comments

eyakcn picture eyakcn  路  3Comments

daryn-k picture daryn-k  路  3Comments

tulika21-zz picture tulika21-zz  路  3Comments

movie4 picture movie4  路  3Comments