I am a novice in NodeJS and I am trying to start with express and express-generator. I have installed express with the command:
C:\project>npm install -g express
Then I've installed the express-generator module:
C:\project>npm install -g express-generator
Then I create a folder for the project and install de dependencies:
C:\project\express> nodetest1
C:\project\nodetest1>npm install
Everything works fine there, but the problem appears when I try to start the server, with the command:
C:\project\nodetest1>npm start
It seems that the service starts but it closes as soon as it starts, result:
> nodetest1#0.0.0 start C:\project\nodetest1
> node ./bin/www
C:\project\nodetest1>
When I try to open localhost:3000 it doesn't work. I have search on the net and I haven't found a solution for it, could someone guide me on how to solve this problem?
Thank you.
Update 1:
After having reinstalled node.js and followed the steps proposed below, now I get an error:
C:\wamp\www\mynewapp>npm start
> mynewapp#0.0.0 start C:\wamp\www\mynewapp
> node ./bin/www
npm ERR! mynewapp#0.0.0 start: `node ./bin/www`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the mynewapp#0.0.0 start script.
npm ERR! This is most likely a problem with the mynewapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls mynewapp
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\wamp\www\mynewapp
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! syscall spawn
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! mynewapp#0.0.0 start: `node ./bin/www`
npm ERR! Exit status -1
npm ERR!
npm ERR! Failed at the mynewapp#0.0.0 start script.
npm ERR! This is most likely a problem with the mynewapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls mynewapp
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\wamp\www\mynewapp
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\wamp\www\mynewapp\npm-debug.log
npm ERR! not ok code 0
C:\wamp\www\mynewapp>
you can solve this issue easily. Go to "packages.json" file then change start :
"scripts": {
"start": "node ./bin/www"
}
and make it "start": "node app.js". Then run the command npm start and the project is not going to work. Now go back and change start again to "start": "node ./bin/www" which is the default value in Express and run the command, npm start. It worked for me.
You need to check in your package.json what npm start is doing. It should have the command to start your app, and it should have a part looking something like this:
"scripts": {
"start": "node app.js"
},
the app.js should have been created by the generator, but given the steps that you described it seems you forgot to generate the app. Try this:
express mynewapp
cd mynewapp
npm install
npm start
try http://www.npmjs.com/package/gennode it's a very easy code generator module for Nodejs projects. The crud controller, route, test and documentation will be automatically generated for you. so you just have to focus on the functionality that makes your sever unique.
Related
I have just moved from linux ubuntu to windows and here first errors. When i try to restart the app i receive this errors.And every time i have to restart the whole computer in order to see the changes.After restarting the whole computer npm start works fine.
i tried to update the npm but no result.
Could anyone help?
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! exproject#1.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the exproject#1.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the exproject package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs exproject
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls exproject
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\sashi\Desktop\nprojects\basicexpress\exproject\npm-debug.log
chage
"scripts": {
"start": "./bin/www"
},
To
"scripts": {
"start": "node ./bin/www"
},
I am trying to compile files with webpack and npm for my reactJS applciation.
When I am running:
npm install --save react-websocket
Its working fine.
Next when I am executing
npm start
getting the following error:
> reactapp#1.0.0 start D:\ReactServer
> webpack-dev-server --hot
'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! reactapp#1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp#1.0.0 start script 'webpack-dev-server -- hot'.
npm ERR! This is most likely a problem with the reactapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs reactapp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls reactapp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\ReactServer\npm-debug.log
Can anybody help me with this?
I think you do not have webpack-dev-server installed on your system.
npm install -g webpack-dev-server
run the above command on cmd/terminal. Hopefully it will resolve your issue.
I am new be to node js . started to set up node js project .
Got error when npm start command is used.
npm start
> sigma#1.1.0 start /usr/local/UserProfile/TitanUI
> http-server -p 8080
sh: http-server: command not found
npm ERR! Linux 2.6.32-504.8.1.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! sigma#1.1.0 start: `http-server -p 8080`
npm ERR! spawn ENOENT
npm ERR! Failed at the sigma#1.1.0 start script 'http-server -p 8080'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sigma package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! http-server -p 8080
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sigma
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sigma
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/UserProfile/TitanUI/npm-debug.log
These are the versions of centos , npm and node js.
centos:6.6
npm:3.10
nodejs:6.7.0
I guess I have latest versions only..Please help me if any one knows about this.
Removed the node modules folder and ran "npm install" and "npm start" again. This solved the above error. Thanks!
i am totally new to node.js and mongodb. I am using the following link: http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/
This procedure worked very fine and got the exact same results. But all of a sudden "npm start" stopped working.
I uninstalled every thing and trying to re-install from step 1 given in this tutorial. when i give the command "npm install -g express" i am not getting any list of http 304's and GETS!! .
As i ignore and continue the procedure, i give the command npm start , but it does not work. the error displayed is shown below
C:\project\nodetest1>npm start
> nodetest1#0.0.0 start C:\project\nodetest1
> node ./bin/www
npm ERR! nodetest1#0.0.0 start: `node ./bin/www`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the nodetest1#0.0.0 start script.
npm ERR! This is most likely a problem with the nodetest1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls nodetest1
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\project\nodetest1
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! syscall spawn
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! nodetest1#0.0.0 start: `node ./bin/www`
npm ERR! Exit status -1
npm ERR!
npm ERR! Failed at the nodetest1#0.0.0 start script.
npm ERR! This is most likely a problem with the nodetest1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls nodetest1
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\ProgramFiles\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\project\nodetest1
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\project\nodetest1\npm-debug.log
npm ERR! not ok code 0
Please help . Thanks in advance.
The error suggests that the ./bin/www directory is not found. Paths specified with a dot are relative to the current directory, so your current directory has to be C:/project/nodetest1 for npm start to work in this case.
There are several issues here.
First, you should upgrade to a newer npm, as the npm that ships with even the latest version of node is out of date. To upgrade npm on Windows, follow the instructions here:
https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows
Second, you may need to do some more troubleshooting on your own to find the problem. npm start just follows the instructions in the package.json. The package.json is telling npm that start means "run node ./bin/www".
What happens when you run that same script from the command line?
cd C:\project\nodetest1
node ./bin/www
Does the file 'bin/www' exist? Is node installed and in your path? These are the issues that you will have to troubleshoot.
Delete the node_modules folder.
Run npm install
And then, re-run your command npm start
The package.json is telling npm that start means "run node ./bin/www".
**but packege.json predefined staring script is npm run serve **
please try this one.
npm run serve
"start": "concurrently \"npm run build:watch\" \"npm run serve\""
One of the possible situation causing this problem might be that the command npm start is giving error is because the current directory that you are in right now and the react app directory is not same. Try navigating your command prompt to the react app location using cd ./your react app location/
I'm getting an error when trying to run a node.js app in elastic beanstalk. I followed the instructions here for an express app, but when I inspect the node.js logs, I can see the node process exits with a permissions error. I'm not sure what to do here?
> express-test#0.0.1-52 start /var/app/current
> src/server.js
sh: src/server.js: Permission denied
npm ERR! express-test#0.0.1-52 start: `src/server.js`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the express-test#0.0.1-52 start script.
npm ERR! This is most likely a problem with the express-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! src/server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls express-test
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.10.35-43.137.amzn1.x86_64
npm ERR! command "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/npm" "start"
npm ERR! cwd /var/app/current
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.4
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/app/current/npm-debug.log
npm ERR! not ok code 0
What do you have in your package.json file in the scripts section?
I'm guessing you forgot to put the beginning part of the command and instead it is trying to execute server.js, which is a js file and isn't executable.
Instead, try:
"scripts": {
"start": "node server.js"
},