7

我刚刚安装了 Node.js,现在我正在尝试运行一个简单的脚本,但我收到以下错误消息:

Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
    at Function.<anonymous> (module.js:383:11)
    at Object.<anonymous> (/home/shawn/.node_libraries/express@2.5.9/index.js:4:21)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)
    at Module.require (module.js:359:17)
    at require (module.js:375:17)
    at Object.<anonymous> (/home/shawn/Documents/Projets/jsonpExchange/server.js:1:77)
    at Module._compile (module.js:446:26)

这是什么意思,我该如何解决?

更新:

$ node -v

v0.6.19

$ npm install express

npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/connect
npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/formidable
npm http 304 https://registry.npmjs.org/formidable
express@2.5.10 ./node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.0 (formidable@1.0.11)
4

2 回答 2

4

当为旧版本的 nodejs 构建一些已安装的包时,会发生此错误。

您使用的是哪个版本的节点?

$ node -v

您是否使用 npm (http://npmjs.org) 来安装软件包?install express 的输出应该是这样的:

$ npm install express
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/connect
npm http 304 https://registry.npmjs.org/mime/1.2.4
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/qs
npm http 200 https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/connect/-/connect-1.9.0.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-1.9.0.tgz
npm http GET https://registry.npmjs.org/formidable
npm http 304 https://registry.npmjs.org/formidable
express@2.5.10 ./node_modules/express
├── qs@0.4.2
├── mkdirp@0.3.0
├── mime@1.2.4
└── connect@1.9.0 (formidable@1.0.11)
于 2012-06-22T21:07:59.487 回答
0

就我而言,我有一个旧的本地(特定于用户)安装的coffee-script.

这是我所做的:

  1. 删除了我的~/.node_modules文件夹
  2. 删除文件夹中的相关二进制~/bin文件
  3. 重新安装coffee-scriptsudo npm install --global coffee-script

现在它可以工作了:)

于 2012-07-31T23:42:05.850 回答