![](/img/trans.png)
[英]nodeenv — not linking grunt when installed via npm install -g?
[英]Grunt install error/s: “should be installed with -g”
我正在嘗試在計算機上安裝Grunt。 我已經閱讀了一些教程並遵循了安裝文檔 ,但是我無法使其正常運行。
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
進行安裝-我知道這意味着“全局”。
在這之后,似乎我無法發出咕unt聲,例如:
$ 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和npm。
首先刪除節點,然后按照說明安裝Brew。 然后,您只需鍵入brew install node
,一切就可以像brew install node
一樣工作。
當您安裝語言環境軟件包npm install
,軟件包請求grunt-cli
是一個依賴項。 不用擔心,此警告並不意味着它損壞了任何東西。
grunt: command not found
將grunt二進制文件添加到您的Path中。 添加它,你會沒事的: https : //unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path
從終端輸出中添加的路徑應為以下路徑: /Users/tonyMac/.node/bin
在Bash中: PATH=$PATH:/Users/tonyMac/.node/bin
(如果您在命令行中運行它,則在前面添加export
命令)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.