这是我package.json
要包含在父项目中的模块的代码:
{
"version": "0.0.1",
"name": "module-name",
"dependencies": {
"express": "3.3.4",
"grunt": "0.4.1",
"grunt-contrib-compass": "0.4.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.4.1",
"grunt-contrib-jshint": "0.6.3",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "0.2.2",
"grunt-contrib-watch": "0.5.1",
"grunt-express-server": "0.4.1",
"grunt-karma": "0.4.5",
"grunt-regex-replace": "0.2.5",
"request": "2.25.0"
},
"scripts": {
"postinstall": "grunt install"
}
}
需要注意的一件事是,此模块包含在私有仓库中,我将其包含在父package.json
类中,例如:"module-name": "git+ssh://git@myserver:user/module-name.git"
postinstall
脚本失败,因为grunt
未找到本地软件包,因为NPM未安装这些本地软件包