"command not found: webpack-dev-server" 的 webpack-dev-server 错误
webpack-dev-server errors with "command not found: webpack-dev-server"
真的不明白为什么我无法将其发送到 运行...我已经完成了以下操作。
npm install -g webpack webpack-dev-server
确认两个都安装成功。
现在,当我尝试执行 webpack-dev-server
时,我得到以下信息:
$ webpack-dev-server --inline --hot
zsh: command not found: 'webpack-dev-server'
永远不要 运行 像我所有其他 npm 模块一样 load/run 很好,无论是本地还是全局。我也尝试将它本地安装到项目中(添加到 package.json、npm install、yadda yadda..)并收到相同的错误。
我是不是漏掉了什么?
根据 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
.
问题是 npm 将全局包安装到 /usr/local/lib/node_modules,这需要 root 权限。
为避免这种情况,您可以使用 Use sudo npm i -g webpack webpack-dev-server。
它对我有用。
真的不明白为什么我无法将其发送到 运行...我已经完成了以下操作。
npm install -g webpack webpack-dev-server
确认两个都安装成功。
现在,当我尝试执行 webpack-dev-server
时,我得到以下信息:
$ webpack-dev-server --inline --hot
zsh: command not found: 'webpack-dev-server'
永远不要 运行 像我所有其他 npm 模块一样 load/run 很好,无论是本地还是全局。我也尝试将它本地安装到项目中(添加到 package.json、npm install、yadda yadda..)并收到相同的错误。
我是不是漏掉了什么?
根据 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
andwebpack-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.mdI installed
webpack
andwebpack-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
.
问题是 npm 将全局包安装到 /usr/local/lib/node_modules,这需要 root 权限。
为避免这种情况,您可以使用 Use sudo npm i -g webpack webpack-dev-server。
它对我有用。