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

NPM dependencies fail to download in certain cases #1761

Closed
rdickert opened this issue Jan 15, 2014 · 2 comments
Closed

NPM dependencies fail to download in certain cases #1761

rdickert opened this issue Jan 15, 2014 · 2 comments

Comments

@rdickert
Copy link
Contributor

@rdickert rdickert commented Jan 15, 2014

Although it only affects outside packages (and therefore perhaps not officially supported), I thought I'd report it in case it affects the next iteration of the package system and Meteorite as we near 1.0 – and in any case, these packages are widely used and expected to work.

It turns that that outside package NPM dependencies may fail to download if the directory /node_modules is present in its parent directories. E.g., if my meteor project is in ~/sites/my_project, the presence of a directory ~/node_modules or ~/sites/node_modules will cause meteor add to fail in some cases.

To reproduce:

  • meteor create a bare project.
  • Add a packages directory and clone in the scss package git clone https://github.com/fourseven/meteor-scss.git.
  • Make sure you have a ~/node_modules directory (assuming your new project is somewhere under your home directory)
  • meteor add meteor-scss Fails.
  • if you remove ~/node_modules and repeat meteor add meteor-scss, it works. Once this process is done, you can put back ~/node_modules, and the project will continue to work, but new meteor adds will fail.

I'm attaching a stack trace below. It appears that perhaps a recursive process is glomming onto the wrong node_modules directory and finding it lacks the module and the also no shrinkwrap to download the package. Here's the link to where the trace fails in bundler.js. I don't know if there are other ways to trigger this bug, but there are some other issues I found that may be related posted here. This was done on Meteor 0.7.1 on OSX 10.9.1.

➜  xerr4  meteor add meteor-scss
npm ERR! missing: socket.io-client@0.9.16, required by socket.io@0.9.16
npm ERR! missing: policyfile@0.0.4, required by socket.io@0.9.16
npm ERR! missing: base64id@0.1.0, required by socket.io@0.9.16
npm ERR! missing: connect@2.8.8, required by express@3.3.8
npm ERR! missing: commander@1.2.0, required by express@3.3.8
npm ERR! missing: range-parser@0.0.4, required by express@3.3.8
npm ERR! missing: mkdirp@0.3.5, required by express@3.3.8
npm ERR! missing: cookie@0.1.0, required by express@3.3.8
npm ERR! missing: buffer-crc32@0.2.1, required by express@3.3.8
npm ERR! missing: fresh@0.2.0, required by express@3.3.8
npm ERR! missing: methods@0.0.1, required by express@3.3.8
npm ERR! missing: send@0.1.4, required by express@3.3.8
npm ERR! missing: cookie-signature@1.0.1, required by express@3.3.8
npm ERR! missing: debug@*, required by express@3.3.8
npm ERR! missing: minimatch@~0.2.11, required by glob@3.2.6
npm ERR! missing: inherits@2, required by glob@3.2.6
npm ERR! missing: wordwrap@~0.0.2, required by optimist@0.3.7
npm ERR! not ok code 0

=> Errors while scanning packages:

While building plugin `meteor-scss` in package `meteor-scss`:
error: couldn't read npm version lock information

While loading plugin `meteor-scss` from package `meteor-scss`:
module.js:338:15: Cannot find module 'node-sass'
  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._.extend.Npm.require (/Users/robert/.meteor/tools/09b63f1ed5/tools/bundler.js:999:22)
  at Package (packages/meteor-scss/plugin/compile-scss.js:2)
  at <runJavaScript-3>:59:4
  at <runJavaScript-3>:66:3

➜  xerr4
➜  xerr4  % Here I renamed  ~/node_modules
➜  xerr4
➜  xerr4  meteor add meteor-scss
meteor-scss: updating npm dependencies -- node-sass...
meteor-scss: Style with attitude.
@glasser
Copy link
Member

@glasser glasser commented Jan 15, 2014

Yeah, this is a pain. Need to take some time to dive into the npm source and figure out how to avoid this. Would accept PRs too :)

rdickert added a commit to rdickert/meteor that referenced this issue Jan 18, 2014
Package code pulled from a git repo does not contain the directory `/node_modules`, as these modules are downloaded during the build process. However, this can confuse NPM prior to build completion.

If the package directory doesn’t  have a '/node_modules' subdirectory, NPM will assume we are not at the package root and will search the directory's parents for one. It will then set the root to any ancestor that does have a '/node_modules' subdir. This can cause the build to fail for downloaded user packages and also Meteor itself if run from checkout.

See also meteor#927
@rdickert
Copy link
Contributor Author

@rdickert rdickert commented Jan 18, 2014

@glasser I took the challenge and chased down the issue. My first PR! Let me know if you have feedback or suggestions.

rdickert added a commit to rdickert/meteor that referenced this issue Jan 30, 2014
Fixes meteor#1761. 2nd try is better targeted – see PR for discussion.
@glasser glasser closed this in d861776 Feb 17, 2014
glasser added a commit that referenced this issue Feb 17, 2014
Fixes #1761.

Package code pulled from a git repo does not contain the directory
`/node_modules`, as these modules are downloaded during the build
process. However, this can confuse NPM prior to build completion.

If the package directory doesn’t have a '/node_modules' subdirectory,
NPM will assume we are not at the package root and will search the
directory's parents for one. It will then set the root to any ancestor
that does have a '/node_modules' subdir. This can cause the build to
fail for downloaded user packages and also Meteor itself if run from
checkout.

See also #927.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.