Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node - how to run app.js?

Tags:

node.js

pug

I am very new to Node.js and I tried to run a project (made by other developer) by having a command in terminal node app.js. But I encountered below error, do you have any idea how to run this project?

I followed few instructions here to run a project.

Error logs below:

Junryls-Mac-mini:app junrylmaraviles$ node app.js  /Users/junrylmaraviles/Desktop/myfolder/mysubfolder/app/app.js:1 (function (exports, require, module, __filename, __dirname) { define('src/app'                                                               ^ ReferenceError: define is not defined     at Object.<anonymous> (/Users/junrylmaraviles/Desktop/myfolder/mysubfolder/app/app.js:1:63)     at Module._compile (module.js:456:26)     at Object.Module._extensions..js (module.js:474:10)     at Module.load (module.js:356:32)     at Function.Module._load (module.js:312:12)     at Function.Module.runMain (module.js:497:10)     at startup (node.js:119:16)     at node.js:902:3 
like image 926
JunM Avatar asked Mar 03 '14 02:03

JunM


People also ask

How do I run a NodeJS command line?

Node. js can run shell commands by using the standard child_process module. If we use the exec() function, our command will run and its output will be available to us in a callback. If we use the spawn() module, its output will be available via event listeners.


1 Answers

Assuming I have node and npm properly installed on the machine, I would

  • Download the code
  • Navigate to inside the project folder on terminal, where I would hopefully see a package.json file
  • Do an npm install for installing all the project dependencies
  • Do an npm install -g nodemon for installing all the project dependencies
  • Then npm start OR node app.js OR nodemon app.js to get the app running on local host

use nodemon app.js ( nodemon is a utility that will monitor for any changes in your source and automatically restart your server)

like image 180
Prakash Tiwari Avatar answered Sep 17 '22 08:09

Prakash Tiwari