2012-06-22 23 views
7

Tôi chỉ vừa mới cài đặt Node.js và bây giờ tôi đang cố gắng để chạy một kịch bản đơn giản, nhưng tôi nhận được thông báo lỗi sau:Lỗi: require.paths bị xóa. Sử dụng node_modules thư mục, hoặc các biến môi trường NODE_PATH thay

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/[email protected]/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) 

có nghĩa là gì và làm thế nào tôi có thể giải quyết nó?

UPDATE:

$ 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 
[email protected] ./node_modules/express 
├── [email protected] 
├── [email protected] 
├── [email protected] 
└── [email protected] ([email protected]) 

Trả lời

4

Lỗi này xảy ra khi một số gói cài đặt sẽ được xây dựng cho một phiên bản cũ của nodejs.

Bạn đang sử dụng phiên bản nút nào?

$ node -v 

Bạn đang sử dụng npm (http://npmjs.org) để cài đặt gói? Kết quả của cài đặt nhanh nên như thế này:

$ 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 
[email protected] ./node_modules/express 
├── [email protected] 
├── [email protected] 
├── [email protected] 
└── [email protected] ([email protected]) 
+3

Bạn cũng có thể cố gắng loại bỏ/home/shaw n/.node_libraries/directory –

+0

$ node -v v0.6.19 – Shawn

+0

$ npm cài đặt nhanh: xem chỉnh sửa của tôi – Shawn

0

Trong trường hợp của tôi, tôi có một địa phương cài đặt (do người dùng cụ thể) cũ của coffee-script.

Dưới đây là những gì tôi đã làm:

  1. xóa ~/.node_modules thư mục của tôi
  2. xóa mã nhị phân có liên quan trong ~/bin thư mục
  3. cài đặt lại coffee-script: sudo npm install --global coffee-script

Bây giờ nó hoạt động :)

Các vấn đề liên quan