Node.js ERROR Error: Cannot find module 'bluebird'

99封情书 提交于 2019-12-23 17:27:41

问题


When I try this,it throw an error,how can I solve it?

$ hexo generate
ERROR Error: Cannot find module 'bluebird'
    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> (/Users/lihz/blog/node_modules/hexo/lib/hexo/index.js:3:15)
    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)
    at require (module.js:380:17)
    at /usr/local/lib/node_modules/hexo-cli/lib/index.js:73:18
    at tryCatcher (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/promise.js:489:31)
    at Promise._settlePromiseAt (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/promise.js:565:18)
    at Promise._settlePromises (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/promise.js:681:14)
Unhandled rejection TypeError: Cannot call method 'then' of undefined
    at /usr/local/lib/node_modules/hexo-cli/lib/index.js:82:22
    at tryCatcher (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/promise.js:489:31)
    at Promise._settlePromiseAt (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/promise.js:565:18)
    at Async._drainQueue (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/async.js:133:10)
    at Async.drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickCallback (node.js:442:13)

回答1:


You might need to install the bluebird package locally. Try

npm install --save bluebird



回答2:


In my case the Bluebird folder was called 'bluebird' and i was importing it as 'Bluebird' (with a capital 'B') so i changed the import string to be 'bluebird' (im working on linux).

Hope this helps someone.




回答3:


I usually use registry to install modules. But I forgot that while downloading hexo-cli. when I run hexo, it responses me 'cannot find bluebird', even though it has been installed.

my solution is:

use registry to install hexo-cli again.

then everything is ok.




回答4:


I'm having the same issue. It looks as though bluebird is not downloading with its' index.js which would exposes all the functions as a module.

If you cd into node_modules/bluebird you may see that it does exist, but there is no index.js. Since there's no index.js node does not know how to require bluebird.


Here are a few items to try:

  1. If you have a "proxying" npm registry, put a namespace on all packages you pull from that repository, and then edit your npm config pull all packages from the public NPM, unless they are namespaced to pull from your private NPM registry. You can see an example below of how to scope configuration to scopes.

    registry=https://registry.npmjs.org/
    @dog:registry=https://npm.dog.com/
    @dog:always-auth=true
    //npm.dog.com/:_authToken="XXXXXXXXXXXX"
    @dog:cafile=/Users/dogboy/.ssh/dogtown.crt
    
  2. Upgrade NPM versions.



来源:https://stackoverflow.com/questions/31378699/node-js-error-error-cannot-find-module-bluebird

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!