Bash 我是否必须在本地安装grunt,或者这只是最佳实践。。。?

Bash 我是否必须在本地安装grunt,或者这只是最佳实践。。。?,bash,gruntjs,Bash,Gruntjs,或者两者都没有 我在全球范围内安装了grunt cli和grunt inst_grunt(){ # installs the grung-cli to # /usr/local/lib/node_modules/grunt-cli sudo npm install -g grunt-cli # installs grunt based upon the package.json file to # /usr/local/lib/node_modules/Grunt

或者两者都没有

我在全球范围内安装了grunt cli和grunt

inst_grunt(){

  # installs the grung-cli to
  # /usr/local/lib/node_modules/grunt-cli
  sudo npm install -g grunt-cli

  # installs grunt based upon the package.json file to 
  # /usr/local/lib/node_modules/Grunt
  sudo npm install -g
 }
我想我可以跑了

 grunt --gruntfile /Users/a/root/config/Gruntfile.js watch
如下文所述:

但是,唉,我犯了这个错误:

如MacBook Air:config a$grunt--Grunfile /Users/a/root/config/Gruntfile.js grunt cli:grunt命令行 接口。(v0.1.13)

致命错误:找不到本地grunt

如果您看到此消息,可能是找不到GrunFile,或者 grunt尚未在本地安装到您的项目中。更多 有关安装和配置grunt的信息,请参阅 入门指南:


grunt文件就在那里,所以我假设它正在寻找本地grunt安装。

您必须在本地安装它,以便在gruntfile中调用它的函数


通过这种方式,您的项目可以指定在package.json文件中应该使用(编辑)哪个版本的Grunt。

那么您是说我必须在本地安装它?如果是,为什么会有全局安装选项?全局安装允许您使用命令行中的包(即运行grunt任务),本地安装允许您使用代码中的模块(即require('grunt'))引用