Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible dependency loop: Cannot find module 'brace-expansion' #330

Closed
dtoubelis opened this issue Jan 4, 2016 · 12 comments
Closed

Possible dependency loop: Cannot find module 'brace-expansion' #330

dtoubelis opened this issue Jan 4, 2016 · 12 comments

Comments

@dtoubelis
Copy link

I've added "sharp": "^0.12.1" to my package.json and I'm using npm install to install the package on Ubuntu 14.04. It is failing with the following message:

> sharp@0.12.1 install /var/lib/jenkins/workspace/WebApp/node_modules/sharp
> node-gyp rebuild

module.js:328
    throw err;
    ^

Error: Cannot find module 'brace-expansion'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/var/lib/jenkins/workspace/WebApp/node_modules/minimatch/minimatch.js:10:14)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
gyp: Call to 'GLOBAL_VIPS_VERSION="7.38.5" node -e "require('./binding').use_global_vips()"' returned exit status 1. while trying to load binding.gyp

Subsequent run of npm instal is successful and I'm able to install and use the package, however, this wrecks havoc with our automated builds.

@dtoubelis
Copy link
Author

It seems like some sort of dependency loop. I had to create a npm-shrinkwrap.json in order to freeze the working configuration. Calling npm install with npm-shrinkwrap.json in place works around this problem.

@lovell
Copy link
Owner

lovell commented Jan 4, 2016

brace-expansion is a dependency of minimatch which is likely to be a dependency of another module that ultimately sharp is dependent upon. It's also a dependency of npm itself.

My best guess here is that you've run into the npm/npm#8152 race condition that I believe has been fixed in npm v3. Are you able to upgrade the globally-installed version of npm?

@lovell lovell added the triage label Jan 4, 2016
@dtoubelis
Copy link
Author

My global version of npm is 3.3.12. It is one that came with nodejs v5.3.0.

@lovell
Copy link
Owner

lovell commented Jan 4, 2016

Ah, in that case this problem looks more like nodejs/node#3922

The stacktrace suggests node itself is looking in /var/lib/jenkins/workspace/WebApp/node_modules/minimatch/... for the minimatch module at require time. I'm not sure why it would do that - perhaps another dependency in WebApp/package.json has:

  1. inserted some kind of require hook that relies on minimatch, or
  2. an older version of minimatch that doesn't specify the brace-expansion dependency

@dtoubelis
Copy link
Author

This is relevant section from my package.json:

  "devDependencies": {
    "auto-reload-brunch": ">= 1.0 < 1.9",
    "chai": "^3.4.1",
    "clean-css-brunch": ">= 1.0 < 1.9",
    "css-brunch": ">= 1.0 < 1.9",
    "hippie": "^0.4.0",
    "javascript-brunch": ">= 1.0 < 1.9",
    "jshint": "~2.6.3",
    "less-brunch": "^1.8.1",
    "mocha": "^2.2.0",
    "mocha-bamboo-reporter": "^1.1.0",
    "stylus-brunch": "^1.8.1",
    "uglify-js-brunch": ">= 1.0 < 1.9"
  },
  "dependencies": {
    "aws-sdk": "^2.1.45",
    "bcrypt": "^0.8.5",
    "bcrypt-nodejs": "^0.0.3",
    "body-parser": "^1.13.3",
    "cache-manager": "^1.2.2",
    "cache-manager-redis": "^0.2.1",
    "connect-flash": "^0.1.1",
    "connect-memcached": "^0.1.0",
    "cookie-parser": "^1.3.5",
    "csurf": "^1.8.3",
    "express": "^4.13.3",
    "express-handlebars": "^2.0.1",
    "express-session": "^1.11.3",
    "handlebars": "^4.0.5",
    "jshint-brunch": "^1.8.0",
    "jsonwebtoken": "^5.4.1",
    "lodash": "^3.10.1",
    "memcached": "^2.1.0",
    "newrelic": "~1.24.0",
    "node-uuid": "^1.4.3",
    "nodemailer": "^1.4.0",
    "nodemailer-ses-transport": "^1.3.0",
    "passport": "^0.2.2",
    "passport-local": "^1.0.0",
    "pg": "^4.4.1",
    "pg-hstore": "^2.3.2",
    "sequelize": "^3.5.1",
    "sharp": "^0.12.1",
    "zxcvbn": "^4.2.0"
  }

I think that should be enough to reproduce the issue.

@dtoubelis
Copy link
Author

Oh BTW, Node.js v5.x is installed directly from the official Nodejs.org repository to a brand new Linode instance with Ansible automation script, so there is no traces of any bundled Node.js on the system. The only thing that happened to it is that it has been upgraded from v5.2.0 to v5.3.0 but it was way before I started using sharp and I did clean reinstall after that.

@lovell
Copy link
Owner

lovell commented Feb 4, 2016

@dtoubelis Have you been able to make any progress with this problem?

@dtoubelis
Copy link
Author

No not really, I run npm install twice and then shrinkwrap it. That is an extra step but it does it for me.

@lovell
Copy link
Owner

lovell commented Feb 4, 2016

@dtoubelis Thanks for the update - I'll leave this open to see if others run into the same problem.

@lovell lovell changed the title npm install fails on Ubuntu 14.04 Possible dependency loop: Cannot find module 'brace-expansion' Mar 2, 2016
@lovell
Copy link
Owner

lovell commented Jul 28, 2016

Closing this as there have been no further reports of a similar problem in the last 6 months.

@lovell lovell closed this as completed Jul 28, 2016
@piyushmanurkar
Copy link

Same for node 8.9.4, npm 5.6.0

@lovell
Copy link
Owner

lovell commented Feb 19, 2018

Repository owner locked and limited conversation to collaborators Feb 19, 2018
@lovell lovell removed the triage label Feb 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants