Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run node app.js file

I am learning node.js and I am trying to run the app.js file using the command node app.js but the bash returns nothing (no errors either). Here are the steps I followed:

$ brew install node

$ sudo npm install -g express

$ sudo npm install -g express-generator

after i get into a new folder I created I run

$ express testsite --hogan -c less

$ cd testsite && npm install

Finally

$ node app.js // returns no errors but nothing back except new command line...

Any help on this would be great.

Thanks!

like image 710
Shivam Avatar asked Apr 20 '14 04:04

Shivam


People also ask

How do I run a .js file?

You can Run your JavaScript File from your Terminal only if you have installed NodeJs runtime. If you have Installed it then Simply open the terminal and type “node FileName. js”. If you don't have NodeJs runtime environment then go to NodeJs Runtime Environment Download and Download it.

Why is node js not working?

Make sure the node path is added, if not added it. After doing this restart Visual Studio or open a fresh command prompt. From the command prompt type 'node -v' to echo the node version installed. You can also add the path to node or any other application directly on the command line.

How do I run a node js file in my browser?

js to structure your JavaScript applications on the client side, you can use Browserify to require JavaScript modules from JavaScript running on the browser. Browsers lack the Node. js platform's require/export and module import systems; therefore, Browserify was developed to make it possible to import Node.


1 Answers

try npm start from testsite directory.

look at the package.json

scripts : { start : node bin/www } 

So you must execute the www under the bin directory.

So instead of node app.js use node bin/www

like image 79
user626818 Avatar answered Sep 28 '22 03:09

user626818