在 13.04 上安装 Grunt js

chr*_*lee 5 nodejs grunt

如何在 Ubuntu 13.04 上安装 grunt?

我尝试通过 NPM 安装它:

sudo npm install -g grunt
Run Code Online (Sandbox Code Playgroud)

然后当我运行 grunt 时:

grunt
Run Code Online (Sandbox Code Playgroud)

但它似乎不起作用,它会引发错误:

path.js:313
        throw new TypeError('Arguments to path.resolve must be strings');
              ^ TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/grunt/bin/grunt:13:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
Run Code Online (Sandbox Code Playgroud)

以下是有关我拥有的节点版本的一些信息:

$ npm -v                                                                      
1.3.8
Run Code Online (Sandbox Code Playgroud)

Tom*_*rae 11

我相信你想要: npm install -g grunt-cli安装命令行工具。您在每个项目中本地安装 grunt(和模块)

文档在这里支持我的话;http://gruntjs.com/getting-started


chr*_*lee 2

看起来这个错误是在有两个版本的 grunt 时发生的。

要查明是否安装了两个版本的 grunt,请在 CLI 中运行:

where grunt或者which grunt

如果您看到多个版本的 grunt:

/usr/local/bin/grunt
/usr/bin/grunt
/usr/local/bin/grunt
/usr/bin/grunt
Run Code Online (Sandbox Code Playgroud)

然后你只需删除其中之一:

rm /usr/local/bin/grunt
Run Code Online (Sandbox Code Playgroud)

写了一篇关于此的文章以获取更多信息。