gpt4 book ai didi

node.js - Grunt 安装错误 : "should be installed with -g"

转载 作者:搜寻专家 更新时间:2023-11-01 00:45:30 26 4
gpt4 key购买 nike

我正在尝试在我的机器上安装 Grunt。我读过一些tutorials并关注 installation docs ,但我无法让它工作。

CLI 使用此命令安装正常:

sudo npm install -g grunt-cli

当我选择本地目录(包含 package.json 和 Gruntfile)和 npm install 时,我看到以下消息:

npm WARN prefer global grunt-cli@0.1.9 should be installed with -g

为什么会这样?我确实安装了 -g - 意思是“全局”,我明白了。

在这之后,我似乎无法运行 grunt,例如:

$ grunt
-bash: grunt: command not found
$ grunt --version
-bash: grunt: command not found

我该如何解决这个问题?我错过了什么?

这是我的完整日志:

$ sudo npm install -g grunt-cli
Password:
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET 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 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 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 GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
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 GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
/Users/tonyMac/.node/bin/grunt -> /Users/tonyMac/.node/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@0.1.10 /Users/tonyMac/.node/lib/node_modules/grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.4)
└── findup-sync@0.1.2 (lodash@1.0.1, glob@3.1.21)
Tonys-iMac:~ tonyMac$ cd projects/testingGrunt
Tonys-iMac:testingGrunt tonyMac$ npm install
npm WARN prefer global grunt-cli@0.1.9 should be installed with -g

最佳答案

你不应该使用 sudo 来安装包。
如果您使用 sudo 安装 node 和 npm 时出现问题。
我看到你使用 OSX,所以相信我,使用 brew packet manager ( http://brew.sh ) 安装 node 并让它为你处理 node 和 npm。

先删除 Node ,然后按照说明安装 Brew。然后,您只需键入 brew install node,一切都会正常运行。

关于node.js - Grunt 安装错误 : "should be installed with -g",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19778249/

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