如何使用Node.js解決「找不到模塊」錯誤? - How do I resolve 「Cannot find module」 error using Node.js?

問題:

After pulling down a module from GitHub and following the instructions to build it, I try pulling it into an existing project using: 從GitHub提取模塊並按照說明進行構建後,我嘗試使用如下方法將其拖入現有項目: node

> npm install ../faye

This appears to do the trick: 這彷佛能夠解決問題: redis

> npm list
/home/dave/src/server
└─┬ faye@0.7.1
  ├── cookiejar@1.3.0
  ├── hiredis@0.1.13
  └── redis@0.7.1

But Node.js can't find the module: 可是Node.js找不到模塊: npm

> node app.js
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'faye'
    at Function._resolveFilename (module.js:334:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (/home/dave/src/server/app.js:2:12)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)

I really want to understand what is going on here, but I'm at a bit of a loss as to where to look next. 我真的很想了解這裏發生了什麼,可是我對接下來的去向有些困惑。 Any suggestions? 有什麼建議麼? cookie


解決方案:

參考一: https://stackoom.com/question/brT6/如何使用Node-js解決-找不到模塊-錯誤
參考二: https://oldbug.net/q/brT6/How-do-I-resolve-Cannot-find-module-error-using-Node-js
相關文章
相關標籤/搜索