Grunt安装错误/ s:“应与-g”一起安装 [英] Grunt install error/s: "should be installed with -g"

查看:128
本文介绍了Grunt安装错误/ s:“应与-g”一起安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的机器上安装Grunt。我已阅读了一些教程并遵循安装文档,但我无法正常工作。

I'm trying to install Grunt on my machine. I have read some tutorials and followed the installation docs, but I can't get it working.

使用此命令,CLI安装正常:

The CLI installs ok using this command:

sudo npm install -g grunt-cli

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

When I select a local directory (containing the package.json and Gruntfile) and npm install, I see the following message:

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

为什么会发生这种情况?我确实安装了 -g - 意思是'全球',我明白了。

Why is this happening? I did install with -g - meaning 'globally', I understand.

之后,似乎我不能运行grunt,例如:

After this, it seems that I cannot run grunt, eg:

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

我该如何解决这个问题?我缺少什么?

How can I fix this? What am I missing?

以下是我的完整日志:

Here is my full log:

$ 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数据包管理器安装节点( http:// brew。

You shouldn't use sudo to install package.
If you use sudo something went wrong when you installed node and npm.
I see that you use OSX so, trust me, install node with brew packet manager (http://brew.sh) and make it handle node and npm for you.

先删除节点,然后按照说明安装Brew。
然后你可以输入 brew install node ,一切都像魅力一样。

Remove node first and then just install Brew following the instruction. Then you can just type brew install node and everything works like a charm.

这篇关于Grunt安装错误/ s:“应与-g”一起安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆