Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

ELIFECYCLE error on npm run dev/prod #40

Closed
shelakel opened this issue May 7, 2015 · 6 comments
Closed

ELIFECYCLE error on npm run dev/prod #40

shelakel opened this issue May 7, 2015 · 6 comments

Comments

@shelakel
Copy link

shelakel commented May 7, 2015

I came across this issue running (Git) bash and command prompt on Windows 8.1:

0 info it worked if it ends with ok
1 verbose cli [ 'c:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info predev [email protected]
6 info dev [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec dev script
9 verbose stack Error: [email protected] dev: `NODE_ENV=development DEBUG=isomorphic500 node index`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (c:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (c:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:14:12)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1015:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid [email protected]
11 verbose cwd c:\dev\isomorphic500
12 error Windows_NT 6.3.9600
13 error argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
14 error node v0.12.2
15 error npm  v2.7.4
16 error code ELIFECYCLE
17 error [email protected] dev: `NODE_ENV=development DEBUG=isomorphic500 node index`
17 error Exit status 1
18 error Failed at the [email protected] dev script 'NODE_ENV=development DEBUG=isomorphic500 node index'.
18 error This is most likely a problem with the isomorphic500 package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     NODE_ENV=development DEBUG=isomorphic500 node index
18 error You can get their info via:
18 error     npm owner ls isomorphic500
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

Excerpt from output when running npm run dev:

> NODE_ENV=development DEBUG=isomorphic500 node index

'NODE_ENV' is not recognized as an internal or external command, operable program or batch file.

It looks like it's a problem with npm on Windows, as just running the intended command (NODE_ENV=development DEBUG=isomorphic500 node index) directly in bash works fine.

Just thought I'd provide some feedback concerning the issue I've encountered and the workaround, for reference purposes.

Thanks for the project, it looks well put together! (P.S. Looking forward to fluxible-router integration)

@gpbl
Copy link
Owner

gpbl commented May 7, 2015

Hi @shelakel, thanks! Fluxible-router is coming soon :-)

It's a problem setting env vars:

NODE_ENV=development DEBUG=isomorphic500 node index

On windows this should work:

SET NODE_ENV=development 
SET DEBUG=isomorphic500 
node index

Please try and comment with the results 👍

@shelakel
Copy link
Author

shelakel commented May 8, 2015

Good stuff.

It seems that using Command Prompt (cmd.exe) fails to start the webpack development server.

Run: cmd.exe /C "set NODE_ENV=development && set DEBUG=isomorphic500 && node index"

Only bash works on Windows. I think opting for the webpack/react-starter scripts approach is more feasible in the long run.

@davidgilbertson
Copy link

@shelakel seconded. I think setting environment vars in the JS is more OS agnostic.
NODE_ENV=development DEBUG=isomorphic500 node index directly in bash did the trick for me, thanks! And thanks @gpbl for the awesome reference!

@davidgilbertson
Copy link

If you're interested, the following works for me (Windows 8.1). In package.json:

"dev": "node index --dev --DEBUG=isomorphic500"

Then in index.js I catch/store any flags:

var args = require('yargs').argv;

if (args.dev) process.env.NODE_ENV = 'development'; // either catch flags specifically

if (args.DEBUG) {
    process.env.DEBUG = args.DEBUG; // or just set whatever's passed in to some flag
}

// Start the server app
require("./src/server");

@gpbl
Copy link
Owner

gpbl commented May 25, 2015

Thanks @davidgilbertson for the suggestion! However i'd go for setting the env vars out of the npm script.

cameronk pushed a commit to cameronk/isomorphic500 that referenced this issue Mar 2, 2016
Add NPM commands, `npm run dev-windows` and `npm run prod-windows`, to fix issues gpbl#40 and so on.
@NBroomfield
Copy link

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

4 participants