包中。json添加“npm安装-g”到脚本预安装。

时间:2021-03-18 07:23:22

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" }

“脚本”:{“预设”:“npm安装- g grunt-cli”},“devDependencies”:{“异步”:“^ 0.9.0”,“呼噜声”:“^ 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”、“标志”:“^ 0.3.2”、“time-grunt”:“^ 1.0.0”、“强调”:“^”1.7.0 }

And then running the command npm install

然后运行命令npm安装。

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? Is there any other way to do it? How can I fix the problem that occurs on the other computers?

它是否正确地使用了package.json?还有别的办法吗?我如何解决在其他计算机上出现的问题?

1 个解决方案

#1


2  

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中添加。您需要安装grunt来运行测试(并让用户决定如何安装它)

#1


2  

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中添加。您需要安装grunt来运行测试(并让用户决定如何安装它)