Weird behaviour on my OSX Yosemite: from one day to another all my node modules installed by npm install -g
were not found via the Terminal.
我OSX Yosemite的怪异行为:从一天到另一天,npm安装的所有节点模块都没有通过终端找到。
I'm not sure if this is due to my node v4.0.0 install the day before.
我不确定这是不是因为我前一天安装的节点v4.0.0。
4 个解决方案
#1
6
Try this
试试这个
echo $(npm config get prefix)/bin
you will get STRING, which should include to your .bash_profile such way
您将获得STRING,该字符串应该包含到.bash_profile中。
export PATH=$PATH:STRING
#2
1
I've finally also used NVM for multiple NodeJS versions management and everything went back under control.
我最后还使用了NVM来管理多个NodeJS版本,一切都在控制之下。
#3
1
Install it globally
全球安装它
npm i -g webpack
If you will work with webpack, install webpack-dev-server too
如果要使用webpack,也要安装webpack-dev-server
npm i -g webpack-dev-server
After I Install this two command I also found errors when run the
安装了这两个命令后,我在运行时也发现了错误
webpack
command so I figure out the problem by changing the version of webpack so I Install
命令,这样我就可以通过修改webpack的版本来解决这个问题
npm install webpack@2.1.0-beta.22
and every thing work fine for me.
对我来说一切都很好。
I recommend you first learn a bit about npm and then webpack. You will struggle a lot. but finally you will find the right destination.
我建议您先了解一下npm,然后再了解webpack。你会挣扎很多,但最终你会找到正确的目的地。
#4
0
Webpack is in your ./node_modules/.bin/ folder so instead of giving just webpack as the command try this.
Webpack在你的。/node_modules/中。bin/ folder,所以不要只提供webpack作为命令,试试这个。
./node_modules/.bin/webpack
You have the npm bin command to get the folder where npm will install executables.
您有npm bin命令来获取npm将安装可执行文件的文件夹。
You can use the scripts property of your package.json to use webpack from this directory which will be exported.
您可以使用包的脚本属性。json用于从这个将要导出的目录中使用webpack。
"scripts": { "scriptName": "webpack --config etc..." } For example:
"scripts": { "build": "webpack --config webpack.config.js" } You can
then run it with:
然后运行它:
npm run build
Or even with arguments:运行npm构建,甚至使用参数:
npm run build -- <args>
运行构建——
This allow you to have you webpack.config.js in the root folder of your project without having webpack globally installed or having your webpack configuration in the node_modules folder.
这允许您拥有webpack.config。在您的项目的根文件夹中,没有安装webpack或在node_modules文件夹中设置webpack配置。
#1
6
Try this
试试这个
echo $(npm config get prefix)/bin
you will get STRING, which should include to your .bash_profile such way
您将获得STRING,该字符串应该包含到.bash_profile中。
export PATH=$PATH:STRING
#2
1
I've finally also used NVM for multiple NodeJS versions management and everything went back under control.
我最后还使用了NVM来管理多个NodeJS版本,一切都在控制之下。
#3
1
Install it globally
全球安装它
npm i -g webpack
If you will work with webpack, install webpack-dev-server too
如果要使用webpack,也要安装webpack-dev-server
npm i -g webpack-dev-server
After I Install this two command I also found errors when run the
安装了这两个命令后,我在运行时也发现了错误
webpack
command so I figure out the problem by changing the version of webpack so I Install
命令,这样我就可以通过修改webpack的版本来解决这个问题
npm install webpack@2.1.0-beta.22
and every thing work fine for me.
对我来说一切都很好。
I recommend you first learn a bit about npm and then webpack. You will struggle a lot. but finally you will find the right destination.
我建议您先了解一下npm,然后再了解webpack。你会挣扎很多,但最终你会找到正确的目的地。
#4
0
Webpack is in your ./node_modules/.bin/ folder so instead of giving just webpack as the command try this.
Webpack在你的。/node_modules/中。bin/ folder,所以不要只提供webpack作为命令,试试这个。
./node_modules/.bin/webpack
You have the npm bin command to get the folder where npm will install executables.
您有npm bin命令来获取npm将安装可执行文件的文件夹。
You can use the scripts property of your package.json to use webpack from this directory which will be exported.
您可以使用包的脚本属性。json用于从这个将要导出的目录中使用webpack。
"scripts": { "scriptName": "webpack --config etc..." } For example:
"scripts": { "build": "webpack --config webpack.config.js" } You can
then run it with:
然后运行它:
npm run build
Or even with arguments:运行npm构建,甚至使用参数:
npm run build -- <args>
运行构建——
This allow you to have you webpack.config.js in the root folder of your project without having webpack globally installed or having your webpack configuration in the node_modules folder.
这允许您拥有webpack.config。在您的项目的根文件夹中,没有安装webpack或在node_modules文件夹中设置webpack配置。