Nodeclipse / nodeclipse

Nodeclipse-1 : Eclipse plugin for Node.js, PhantomJS development (Nodeclipse core plugin); Maven and Gradle (with Android) plugins
https://nodeclipse.github.io/
158 stars 78 forks source link

NPM install issue - bson module didn't build #177

Open ghost opened 9 years ago

ghost commented 9 years ago

I am reporting this issue for the records mostly - in case it will lineup with another thread one day...

Building a new MEAN stack project from IDE every module dependencies in package.json file were installed from Run As... > npm install but one: mongoose.

mongoose depends on mongodb that depends on bson module: the bson module didn't build from IDE therefore mongoose installation failed.

What let me think this is not a module but an IDE issue is quite simple: $ npm install from a command line is working just fine.

paulvi commented 9 years ago

That is quite possible, because when running npm install from within Eclipse, Java runs in process environment, that is different from OS shell. (I know now better after making simple Maven and Gradle plugins for Eclipse)

What is needed is to know what new process environment lacks, it may be some environment variable

Please add postinstall script in package.json and compare

    "scripts": {
        "test": "echo \"Error: no test specified! Configure in package.json\" && exit 1",
        "postinstall": "node pev.js"
    },

pev.js

console.log(process.env);

no more others ideas so far

ghost commented 9 years ago

pev.js was never called: looks like NPM exits before reaching it - is this making sense?

I wonder how npm install was implemented in the first place: will it be possible to send it to OS shell instead? I could be wrong but it actually rings a bell: is this not quite similar to an express 4 project generator to be run from OS shell we discussed weeks ago?

paulvi commented 9 years ago

to send it to OS shell instead?

Just try to lunch other process from Node and Java and you will see that it will run in bare environment quite different from OS shell. OS shell is cmd on windows.

Try check if package.json has e.g. preinstall option.

The Java code for launching npm is old https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/npm/LaunchConfigurationDelegate.java and it lacks environment variable handling I added for Node.js

But before blindly adding more environment variables, it would be nice to have some reference docs... What is minimal and needed for npm to run ?

ghost commented 9 years ago

0 info it worked if it ends with ok 1 verbose cli [ '/opt/local/bin/node', '/opt/local/bin/npm', 'install' ] 2 info using npm@2.1.6 3 info using node@v0.10.33 4 verbose install where, deps [ '~/Projects/mean', 4 verbose install [ 'express', 4 verbose install 'express-session', 4 verbose install 'body-parser', 4 verbose install 'cookie-parser', 4 verbose install 'serve-favicon', 4 verbose install 'morgan', 4 verbose install 'mongoose', 4 verbose install 'jade' ] ] 5 verbose install where, peers [ '~/Projects/mean', [] ] 6 info preinstall meanstack@0.0.0 7 verbose unsafe-perm in lifecycle true 8 info meanstack@0.0.0 Failed to exec preinstall script 9 verbose stack Error: meanstack@0.0.0 preinstall: node pev.js 9 verbose stack spawn ENOENT 9 verbose stack at errnoException (child_process.js:1001:11) 9 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:792:34) 10 verbose pkgid meanstack@0.0.0 11 verbose cwd ~/Projects/mean 12 error Darwin 14.0.0 13 error argv "/opt/local/bin/node" "/opt/local/bin/npm" "install" 14 error node v0.10.33 15 error npm v2.1.6 16 error code ELIFECYCLE 17 error errno ENOENT 18 error syscall spawn 19 error meanstack@0.0.0 preinstall: node pev.js 19 error spawn ENOENT 20 error Failed at the meanstack@0.0.0 preinstall script. 20 error This is most likely a problem with the meanstack package, 20 error not with npm itself. 20 error Tell the author that this fails on your system: 20 error node pev.js 20 error You can get their info via: 20 error npm owner ls meanstack 20 error There is likely additional logging output above. 21 verbose exit [ 1, true ]

paulvi commented 9 years ago

I don't see added value in this log

paulvi commented 9 years ago

@nodeleaf I have added similar handling on envVar to npm launch. But I am not testing it against bson module.

So once 0.18 is released, we can return and check this issue.