This topic created in 4502 days ago, the information mentioned may be changed or developed.
Supplement 1 Jan 29, 2014 可能说的不是很清楚,举个例子。
比如我用Yeoman新建了一个项目,生成了package.json
{
"name": "d",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-autoprefixer": "~0.4.0",
"grunt-concurrent": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.3.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-google-cdn": "~0.2.0",
"grunt-newer": "~0.5.4",
"grunt-ngmin": "~0.0.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.0",
"jshint-stylish": "~0.1.3",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.1"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "grunt test"
}
}%
如果运行npm install,所有依赖会被安装到node_modules目录下。
于是我的每个项目下面都有一个庞大的node_modules目录,而且每次新建项目,安装依赖都要花一些时间。
我希望把所有依赖安装到全局目录下,然后让node在require的时候根据package.json指定的版本在全局目录找到对应的文件并加载。
就像Ruby的Gem和Java的Maven一样。
不知道有什么办法么?