我有一個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