Reputation: 69
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)
Upvotes: 5
Views: 34204
Reputation: 473
In my case, this error came up when I had installed bluebird in the wrong directory.
When I downloaded Bluebird from my home directory
myuser@raspberrypi:~ $ sudo npm install --save bluebird
it is installed in ~/node_modules
(and I got some warnings by doing so), and I had to include it by using
var Promise = require('/usr/lib/node_modules/bluebird');
When I install Bluebird from the /usr/lib directory using
myuser@raspberrypi:/usr/lib $ sudo npm install --save bluebird
(no warnings), it is installed in /usr/lib/node_modules
(next to the existing npm
directory), and I had to include it by using
var Promise = require('/usr/lib/node_modules/bluebird');
So make sure you are aware of where the module is installed and that you refer to it accordingly. In general, here is a description where require
looks for modules in nodejs.
Upvotes: 0
Reputation: 351
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.
Upvotes: 1
Reputation: 1
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.
Upvotes: 0
Reputation: 14226
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:
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
Upgrade NPM versions.
Upvotes: -1
Reputation: 651
You might need to install the bluebird package locally. Try
npm install --save bluebird
Upvotes: 17