grunt gr-6ren">
gpt4 book ai didi

javascript - Windows 7 专业版上的 "Fatal error: Unable to find local grunt."

转载 作者:搜寻专家 更新时间:2023-10-31 23:35:16 25 4
gpt4 key购买 nike

如果我想启动 grunt,我会收到以下消息:

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

运行 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)

在用户目录下输入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

但是当我进入项目目录时出现相同的信息!

operating system: 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

我设置的环境变量:

变量名:grunt路径:C:\Users\dev_user\AppData\Roaming\npm\grunt然后推出新电脑

有没有人知道为什么消息 Fatal error: Unable to find local grunt. coming?

最佳答案

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

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

npm install -g grunt

或在本地通过以下命令:

npm install grunt

您冷读了 official doc 中的 grunt-cli

来自@Matthew Bakaitis 的注释:

Installing grunt globally is discouraged

It's good practice as grunt-cli loads a global version first (if I recall). If a project was expecting a specific version of grunt, installing globally would break this. Also, if you are depending upon grunt for your builds, why wouldn't you install it as a dependency and list it in package.json? There's a huge assumption that other developers or the target system will have grunt installed globally if you aren't adding as a dependency in package.json. Given the usage situations for grunt, I can't think of many situations where a global install would be better.

关于javascript - Windows 7 专业版上的 "Fatal error: Unable to find local grunt.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31809653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com