Unable to run server with node - node.js

I'm new to node js and programming. I have problems running the server. This is what I did
1) Install Express
sudo npm install -g express-generator
2) Install dependencies
cd . && sudo npm install
When I run in terminal:
node app.js OR node app
There is no response on whether the server is running and chrome says that no data is received when I route to localhost:3000. I later found out that the correct way was to run
npm start
instead, but I got this:
npm ERR! express#0.0.1 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the express#0.0.1 start script.
npm ERR! This is most likely a problem with the express 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 express
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "start"
npm ERR! cwd /Users/apple/Documents/javascript/express
npm ERR! node -v v0.11.14-pre
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/apple/Documents/javascript/express/npm-debug.log
npm ERR! not ok code 0
What's wrong?

What did you get in return when you run node app.js?
Also, make sure your app.js is inside the folder you are at.

Express generator does not generate an express for you, it only installs express tool to generate projects.
sudo npm install -g express-generator
Once express-generator is installed; issue express to generate the project for you;
$ express myapp
// generate myapp with initial express files
$ cd myapp && npm install
// now you run the app
$ ./bin/www
// or
$ npm start

Related

Deploying to App Engine generates error with gulp?

What I wrote in terminal to deploy as usual:
gcloud app deploy
The error I get:
Application startup error:
> meanjs#0.5.0 start /app
> gulp
sh: 1: gulp: not found
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! meanjs#0.5.0 start: `gulp`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the meanjs#0.5.0 start script 'gulp'.
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 meanjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs meanjs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls meanjs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /app/npm-debug.log
Using Mean.js : https://github.com/meanjs/mean
Can't find the npm debug log.
P.S.: I did install gulp globally with
$ sudo npm install gulp-cli -g
First, you don't need to use sudo.
You can fix your error by typing this in terminal:
npm config set prefix ~/npm
# add this to your .bashrc (or .zshrc or whatever you are using)
export PATH="$PATH:$HOME/npm/bin"
Then re-install without sudo.
Hope this helps!
It seems that you did not install gulp in your server. Try to re-install gulp in your server with NodeJS and npm on your server and then install gulp with required packages it may resolve an error.
Please review an error you may find a solution
npm ERR! Make sure you have the latest version of node.js and npm
installed.
Install gulp in your project
npm install gulp
Install gulp globally.
npm install gulp -g
It was an issue with the NODE_ENV.
It would not find the gulp dependency in production, so I had to change my package.json and put everything in "dependencies" instead of using some in "dev_dependencies".

npm start doesn't work after i do npm unlink

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/myName/.nvm/versions/node/v5.12.0/bin/node" "/Users/myName/.nvm/versions/node/v5.12.0/bin/npm" "start"
npm ERR! node v5.12.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! appName#1.5.1 start: `ember server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appName start script 'ember server'.
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 appName package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ember server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs appName
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls appName
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/myName/Documents/Dev/ember-project-name/npm-debug
I linked gooey, one of my projects, to another project: ember, now i wanted to unlink them
so i did npm unlink
then npm start didn't work no matter what i did.
things I've tried:
npm install several times,
bower install several times,
rm -rf node_modules
rm -rf bower_components
npm install several times
npm start kept giving errors, like can't find some file in gooey or tell author that ember server failed
The solution:
option 1:
first do npm link so that it installs everything it needs
then npm install, then npm start will start working again.
option2:
if you want to unlink, do:
npm unlink
npm update
npm start
that should work too.
try npm install again before npm start if you have problems.

npm start command gives error : http-server:command not found , code: ELIFECYCLE

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!

Phantomjs node module install for Phantomjs2.0

I do have a PhantomJS 2.0 installed and running on machine.
whenever I try to install karma-phantomjs-launcher.
I am ending with following error
$npm install
npm WARN package.json karma-tap#1.0.3 No repository field.
phantomjs#1.9.19 install /root/ravi/strongloop/request/request/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
node install.js
Found PhantomJS at /bin/phantomjs ...verifying
PhantomJS detected, but wrong version 2.0.0 # /bin/phantomjs.
npm ERR! phantomjs#1.9.19 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs#1.9.19 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
Is their any way to start working with karma-phantomjs-launcher with existing PhantomJS2.0 .

npm start giving error in node.js

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/

Resources