[英]package.json add “npm install -g” to scripts preinstall
When writing package.json
: 在编写
package.json
:
"scripts": { "preinstall": "npm install -g grunt-cli" }, "devDependencies": { "async": "^0.9.0", "grunt": "^0.4.5", "grunt-contrib-connect": "^0.9.0", "grunt-contrib-cssmin": "^0.10.0", "grunt-contrib-jshint": "^0.10.0", "grunt-contrib-uglify": "^0.6.0", "grunt-contrib-watch": "^0.6.1", "jit-grunt": "^0.9.0", "marked": "^0.3.2", "time-grunt": "^1.0.0", "underscore": "^1.7.0" }
And then running the command npm install
然后运行命令
npm install
It works on some computers but on some I get this error: http://pastebin.com/rYUwhV5k 它适用于某些计算机,但有些我得到这个错误: http : //pastebin.com/rYUwhV5k
Is it proper use of the package.json
? 是否正确使用
package.json
? Is there any other way to do it? 还有其他办法吗? How can I fix the problem that occurs on the other computers?
如何解决其他计算机上出现的问题?
According to the npm documentation "NOTE: INSTALL SCRIPTS ARE AN ANTIPATTERN" https://docs.npmjs.com/misc/scripts 根据npm文档“注意:安装脚本是反地球” https://docs.npmjs.com/misc/scripts
In your case, probably best to just add in the readme.md that you need to have grunt installed to run the tests (and let the user decides how to install it) 在您的情况下,最好只是添加readme.md,您需要安装grunt来运行测试(并让用户决定如何安装它)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.