bower: Error: Cannot find module 'internal/fs'

Output of bower -v && npm -v && node -v:

1.8.0
3.10.9
v7.1.0

Steps to reproduce the issue:

  1. clone https://github.com/officert/mongotron
  2. run npm i

Describe the results you received:

Looks like the old version of graceful-fs doesn’t work anymore (on node 7?). Latest version from git works fine.

> Mongotron@1.0.0-alpha.5 postinstall /tmp/mongotron
> bower install && gulp dev-sym-links

module.js:474
    throw err;
    ^

Error: Cannot find module 'internal/fs'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at evalmachine.<anonymous>:17:20
    at Object.<anonymous> (/tmp/mongotron/node_modules/bower/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN mongodb-core@1.2.30 requires a peer of kerberos@~0.0 but none was installed.
npm ERR! Linux 4.8.6-2-ck
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i"
npm ERR! node v7.1.0
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! Mongotron@1.0.0-alpha.5 postinstall: `bower install && gulp dev-sym-links`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Mongotron@1.0.0-alpha.5 postinstall script 'bower install && gulp dev-sym-links'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Mongotron package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install && gulp dev-sym-links
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs Mongotron
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls Mongotron
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /tmp/mongotron/npm-debug.log

Describe the results you expected: it should work fine

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 19
  • Comments: 23

Most upvoted comments

@BrennerSpear try run bower locally (npm install bower) and

node_modules/bower/bin/bower install

works for me.

@AlokJoshi Glad to help. The point here is that your global bower instance is out of date in relation to the node version. I suggest to uninstall the global bower instance, then install it again and it should work globally.

@oliverjanik I suppose this problem is related to a mismatch between node and bower versions.

I used to manage packages with an old bower version i installed globally (-g option) months and months ago. Then I recently upgraded node to 7.6.0 and my global bower stopped working.

So i’ve

  • npm install bower
  • node_modules/bower/bin/bower install whatever

Also, one should remove his global bower instance and replace it with a fresh one.

+1, windows node v7.4.0 npm 4.0.5

Running “bower -v” failed with the same error message. Hence I (re-)installed bower by “npm install bower -g” and it installed version 1.8.0. bower 1.8.0

Well, the good thing is that the error message is now gone! After this I could install the package I wanted in the first place.

FWIW I get this error when when the bower command is in both my nvm installed global node packages as well as my /usr/local/lib/node_modules. The former being installed via an npm i bower -g. when I do a which bower before installing the latest bower I get /usr/local/bin/bower that’s aliased to /usr/local/lib/node_modules/bower/bin/bower. After I install I get /Users/cwd/.nvm/versions/node/v8.6.0/bin/bower but this isn’t the version that seems to execute. The older one does. Executing directly from /Users/cwd/.nvm/versions/node/v8.6.0/bin/bower seems to work just fine so I think it’s an symlinking or PATH issue. At least in my case

just installing (globally) bower again worked for me npm install -g bower

Install bower and put bower command path into system environment path…

  • install bower
  • npm config get prefix
  • put into system environment path. It is worked for me after facing the error several days.

@AlokJoshi try to move to a different directory and install a local bower instance

  • npm install bower
  • node_modules/bower/bin/bower update

What’s the output?

@brazorf yes, reinstalling bower globally solves the problem. I think the issue can be closed.

OSX El Capitan (10.11.6)

npm -v : 4.0.5
node -v: 7.4.0
bower -v gives me => Error: Cannot find module 'internal/fs'

using n (the node version manager) I switched to node v4.4.2 and then did bower install. I was on bower 1.5.x, it suggested I update to bower 1.8.0. I updated it, and then switched back to node 7.4.0, at which point bower -v gives me 1.8.0, and I can successfully bower install whatever project packages I want.