我如何使用本地版本的模块node.js.例如,在我的应用程序中,我安装了coffee-script:
npm install coffee-script
Run Code Online (Sandbox Code Playgroud)
这将安装它./node_modules并且coffee命令在./node_modules/.bin/coffee.当我在项目的主文件夹中时,有没有办法运行此命令?我想我正在寻找类似于bundle exec捆绑器的东西.基本上,我想指定一个与项目有关的每个人都应该使用的咖啡脚本版本.
我知道我可以添加-g标志来全局安装它,这样咖啡在任何地方都可以正常工作,但如果我想在每个项目中使用不同版本的咖啡呢?
我比平时更加谨慎,因为我npm对过去的行为感到困惑.
我在Mac上,并通过安装的node.js brew install node.
现在我想jslint.js在命令行上运行作为命令,jslint我发现完成此操作的规范方法是sudo npm install -g jslint使用此输出成功运行:
$ sudo npm install -g jslint
npm http GET https://registry.npmjs.org/jslint
npm http 200 https://registry.npmjs.org/jslint
npm http GET https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http 200 https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http GET https://registry.npmjs.org/nopt
npm http 200 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http 200 https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http 200 https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/abbrev/-/abbrev-l.0.4.tgz
npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
/usr/local/share/npm/bin/jslint -> /usr/local/share/npm/lib/node_modules/jslint/
bin/jslint.js
jslint@0.1.9 /usr/local/share/npm/lib/node_modules/jslint
??? …Run Code Online (Sandbox Code Playgroud) 在将操作系统更新为Mavericks后,我无法在终端上执行npm命令.
当我尝试这个:node /usr/local/lib/node_modules/npm/bin/npm-cli.js -v它正在工作并显示版本1.4.3
我不知道这里发生了什么,有谁可以帮助我?谢谢