"致命错误:无法找到当地的咕噜声." 在windows7专业

web*_*r57 3 javascript install node.js npm gruntjs

我想开始咕噜咕噜,我得到以下信息:

c:\repositories\kunde_1\themes-projekt_1\projekt_1-responsive\source>grunt
grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
Run Code Online (Sandbox Code Playgroud)

在运行grunt时你会看到:

C:\Users\dev_user>npm install -g grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http 304 https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/resolve
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/findup-sync
npm http 304 https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
C:\Users\dev_user\AppData\Roaming\npm\grunt -> C:\Users\dev_user\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt
grunt-cli@0.1.13 C:\Users\dev_user\AppData\Roaming\npm\node_modules\grunt-cli
+-- nopt@1.0.10 (abbrev@1.0.7)
+-- resolve@0.3.1
+-- findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11)
Run Code Online (Sandbox Code Playgroud)

在用户目录中输入grunt:

C:\Users\dev_user>grunt
grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
Run Code Online (Sandbox Code Playgroud)

但是当我进入项目目录时会出现同样的消息!

操作系统:windows 7 Professional
npm -version:1.3.5
node --version:v0.10.15

C:\Users\dev_user>npm ls -g
C:\Users\dev_user\AppData\Roaming\npm
+-- coffee-script@1.9.3
+-- grunt-cli@0.1.13
  +-- findup-sync@0.1.3
  ¦ +-- glob@3.2.11
  ¦ ¦ +-- inherits@2.0.1
  ¦ ¦ +-- minimatch@0.3.0
  ¦ ¦   +-- lru-cache@2.6.5
  ¦ ¦   +-- sigmund@1.0.1
  ¦ +-- lodash@2.4.2
  +-- nopt@1.0.10
  ¦ +-- abbrev@1.0.7
  +-- resolve@0.3.1
Run Code Online (Sandbox Code Playgroud)

我设置的环境变量:

变量名称:grunt 路径:C:\Users\dev_user\AppData\Roaming\npm\grunt 然后启动新计算机

有没有人知道为什么消息致命错误:无法找到本地咕噜声.未来?

Art*_*kii 5

安装grunt-cli不会安装Grunt任务运行器.grunt-cli是命令行界面,允许同时在同一台机器上安装多个版本的Grunt.

要安装,grunt您需要通过以下命令全局安装它:

npm install -g grunt
Run Code Online (Sandbox Code Playgroud)

或通过以下命令在本地:

npm install grunt
Run Code Online (Sandbox Code Playgroud)

grunt-cli官方文档中冷读了

来自@Matthew Bakaitis的说明:

不鼓励在全球范围内安装grunt

这是一个很好的做法,因为grunt-cli首先加载一个全局版本(如果我记得的话).如果一个项目期望特定版本的grunt,全局安装将打破这个.另外,如果您依赖于构建的grunt,为什么不将它作为依赖项安装并将其列在package.json中?如果您不在package.json中添加作为依赖项,那么其他开发人员或目标系统将全局安装grunt是一个巨大的假设.鉴于grunt的使用情况,我无法想到全局安装会更好的许多情况.