0
我試圖獲得最簡單的node.js腳本來運行。這裏是JavaScript文件:爲什麼我不需要在node.js中快速運行
server.js
require("express");
我使用regulare節點命令啓動腳本:
$ node server.js
但我得到一個錯誤:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function.<anonymous> (module.js:378:11)
at Object.<anonymous> (/home/shawn/.node_libraries/[email protected]/index.js:4:21)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/shawn/Documents/Projets/passingData/server.js:3:15)
at Module._compile (module.js:441:26)
發生了什麼事?
UPDATE
有趣的是,使用npm install express
輸出了類似的結果:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function.<anonymous> (module.js:378:11)
at Object.<anonymous> (/home/shawn/.node_libraries/[email protected]/index.js:4:21)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/usr/lib/nodejs/fstream/lib/dir-reader.js:11:13)
at Module._compile (module.js:441:26)
你已經完成'npm install express'了嗎? – sntran
'npm install express'也會導致錯誤,請參閱我的編輯。 – Shawn
看起來像你有老npm。嘗試將node.js和npm更新爲當前的穩定版本。 –