簡體   English   中英

Grunt安裝在Ubuntu上但沒有工作

[英]Grunt installed on Ubuntu but not working

我通過在終端中執行以下命令安裝了Grunt:

sudo apt-get install nodejs

sudo apt-get install npm

npm install -g grunt-cli

下面是執行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/resolve
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/findup-sync
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/lodash
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/abbrev
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/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.7)
└── findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11)

Grunt應該全局安裝,但是當我在終端上嘗試grunt --version時,它顯示如下:

/usr/bin/env: node: No such file or directory

我已經嘗試將/usr/local/lib/node_modules/grunt-cli/bin到〜/ .bashrc中,但這沒有幫助。

即使我已經嘗試通過進入/usr/local/lib/node_modules/grunt-cli/bin來執行grunt命令,但沒有希望。

請幫我。

編輯:這是sudo apt-get install nodejs的輸出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp javascript-common libc-ares-dev libjs-node-uuid libssl-dev libssl-doc
  libv8-3.14-dev rlwrap zlib1g-dev
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 261 not upgraded.
Need to get 0 B/684 kB of archives.
After this operation, 3,116 kB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 172429 files and directories currently installed.)
Preparing to unpack .../nodejs_0.10.25~dfsg2-2ubuntu1_amd64.deb ...
Unpacking nodejs (0.10.25~dfsg2-2ubuntu1) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up nodejs (0.10.25~dfsg2-2ubuntu1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

這是來自/usr/local/binls -ln的輸出

lrwxrwxrwx 1 0 0 39 Jul  2 00:07 grunt -> ../lib/node_modules/grunt-cli/bin/grunt
lrwxrwxrwx 1 0 0 21 Jul  1 23:50 node -> /usr/local/bin/nodejs

/usr/bin/env: node: No such file or directory告訴你一切。 當你apt-get install nodejs我相信它會將nodejs而不是node放入你的/usr/local/bin 所以只需要符號鏈接

sudo ln -s /usr/local/bin/nodejs /usr/local/bin/node

它應該工作。

編輯 :它會

sudo ln -s /usr/bin/nodejs /usr/bin/node

為你的情況。

您還必須在項目文件夾中安裝grunt。 grunt-cli包只是一個存根,它引用了項目的node_modules文件夾中的grunt包。

npm install grunt

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM