我有一个Gruntfile来安装一些npm并使其他功能。Grunt在本地安装node_modules
的问题是:NPM的下载工作正常,但在下载
/User/my_user/node_modules
全球node_modules我愿意在本地的gruntfile下载NOM我的项目中没有动态指定路径。
这是我的呼噜声文件的一部分:
module.exports = function(grunt) {
grunt.initConfig({
shell: {
install: {
options: {
stdout: true,
stderr: true
},
command: [
"npm install grunt-contrib-sass",
"npm install node-sass",
"npm install grunt-contrib-less",
"npm install less",
"npm install grunt-contrib-watch",
"npm install grunt-contrib-clean",
"npm install grunt-contrib-copy",
"npm install grunt-csso",
"npm install grunt-deployments"
].join("&&")
},
install_test: {
options: {
stdout: true,
stderr: true
},
command: [
"sudo npm install -g phantomjs",
"npm install -g casperjs",
"mkdir app/Test/Frontend",
"sudo chmod -R 777 app/Test/Frontend"
].join("&&")
},
}
});
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-csso");
grunt.loadNpmTasks("grunt-rsync");
grunt.registerTask("install", [
"shell:cake_tmp",
"shell:install",
"shell:install_test"
]);
};
,我这样做后:
sudo npm install grunt
sudo npm install grunt-shell
grunt install
返回我的错误,它没有找到模块,因为不在本地,但在全球范围内..
我该如何解决?
谢谢
确保你的shell命令在您的CWD拼命地跑。 –
我不明白你为什么把这些东西放在你的Gruntfile中。看起来他们应该在'package.json'中,然后用'npm install'一起安装。 – jakerella