0

我通过源代码在 ubuntu 14.04 上安装了 nodejs 和 npm。

root@wemet:~/ang# npm version
{ http_parser: '1.0',
node: '0.10.34',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.30',
zlib: '1.2.8',
modules: '11',
openssl: '1.0.1j',
npm: '1.4.28' }

我安装了 yo 和 generate-angular 作为全局这是我本地的完整包安装: https ://gist.github.com/thinksource/ba33f0cad073f3d4dc46

当我想做的时候:

root@wemet:~/ang# yo angular

module.js:340
    throw err;
      ^
Error: Cannot find module '../../string/is-string'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/node_modules/insight/n
ode_m odules/inquirer/node_modules/cli-color/node_modules/es5-ext/array/from/shim
.js:9:22)
    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 Module.require (module.js:364:17)

我不知道什么是 is-string 模块。我在https://www.npmjs.com/上查看它,但找不到它。

当我运行凉亭缓存清理时:

root@wemet:~/ang# npm i make-iterator --save-dev
info trying registry request attempt 1 at 00:21:04
http GET https://registry.npmjs.org/make-iterator
http 200 https://registry.npmjs.org/make-iterator
info trying registry request attempt 1 at 00:21:04
http GET https://registry.npmjs.org/for-own
http 200 https://registry.npmjs.org/for-own
info trying registry request attempt 1 at 00:21:05
http GET https://registry.npmjs.org/for-in
http 200 https://registry.npmjs.org/for-in
make-iterator@0.1.1 node_modules/make-iterator
└── for-own@0.1.2 (for-in@0.1.3)
root@wemet:~/ang# bower cache clean

module.js:340
throw err;
      ^
Error: Cannot find module '../function/makeIterator_'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/node_modules/mout/
rray/collect.js:2:20)
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 Module.require (module.js:364:17)

我找到了模块 make-iterator,但即使我安装了 make-iterator,当我运行 bower cache clean 时仍然会遇到错误。

4

2 回答 2

0

我遇到了问题,我需要将我的 npm 版本从 1.4.28 升级到 2.1.2。感谢您的关注。

于 2014-12-18T01:01:43.213 回答
0

@user504909的回答会解决问题,但是好的解决方案是升级Nodejs版本从0.10.34到升级版本0.12.0的结果Nodejsnpm版本也会从升级1.4.282.1.2

Nodejs根据nodesource 博客升级版本:

# Note the new setup script name for Node.js v0.12
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -

# Then install with:
sudo apt-get install -y nodejs

有关OS升级Nodejs版本的答案 ->请参阅此链接Ubuntu

于 2015-06-13T21:02:32.580 回答