I am trying node.js for the first time and having some teething problems. I have installed express at w:/nodejs/app/animaltest/package.json. the app is called 'animalTest'
{
"name": "animalTest",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.9.0",
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"morgan": "~1.3.0",
"serve-favicon": "~2.1.3",
"debug": "~2.0.0",
"hjs": "~0.0.6",
"less-middleware": "1.0.x"
}
}
When I try to launch the app by typing 'npm start' I get the following error from the command prompt. Is there a reference for errors? for instance 'not OK code 0' isn't very helpful.
0 info it worked if it ends with ok
1 verbose cli [ 'W:\\nodejs\\\\node.exe',
1 verbose cli 'W:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@1.4.28
3 info using node@v0.10.32
4 verbose node symlink W:\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart animalTest@0.0.0
7 info start animalTest@0.0.0
8 verbose unsafe-perm in lifecycle true
9 info animalTest@0.0.0 Failed to exec start script
10 error animalTest@0.0.0 start: `node ./bin/www`
10 error Exit status 8
11 error Failed at the animalTest@0.0.0 start script.
11 error This is most likely a problem with the animalTest package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error node ./bin/www
11 error You can get their info via:
11 error npm owner ls animalTest
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "W:\\nodejs\\\\node.exe" "W:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd W:\nodejs\app\animalTest
15 error node -v v0.10.32
16 error npm -v 1.4.28
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]
I had to edit package.json to reflect the location of my app: - "start": "node nodejs/app/animalTest/bin/www" to replace the default .bin/www
To initialise the app I had to type npm start only when I was in the animalTest directory in the command prompt
Thanks to those people that commented.
I was able to solve this by editing the bin\www file.
This problem only appears for Windows not for Mac or Linux.
You simply have to remove the crunchbang #!/usr/bin/env node in the first line.
I hope this solves your problem.