How to run app.js in nodejs?

0 votes

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 anyone have idea how to run this project?

Error logs below:

Junryls-Mac-mini:app Niroj$ node app.js

/Users/Niroj/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/Niroj/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
Oct 13 in Node-js by kartik
• 35,820 points
166 views

1 answer to this question.

0 votes

Hello @kartik,

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

Hope this helps!!

Thank you!!

answered Oct 13 by Niroj
• 78,120 points

Related Questions In Node-js

0 votes
1 answer

How to write files in Node.js?

Hello @kartik, Currently there are three ways to ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
97 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
416 views
0 votes
1 answer

How to uninstall npm modules in node js?

Hello @kartik, The command is simply: npm uninstall ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
573 views
0 votes
1 answer

How to process POST data in Node.js?

Hello @kartik, You can use the querystring module: var qs = ...READ MORE

answered Jul 9 in Node-js by Niroj
• 78,120 points
447 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27 in Java-Script by Niroj
• 78,120 points
448 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5 in Java-Script by Niroj
• 78,120 points
697 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8 in PHP by Niroj
• 78,120 points
91 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
87 views
0 votes
1 answer

How to run node.js app forever when console is closed?

Hello @kartik, You may also want to consider ...READ MORE

answered Oct 14 in Node-js by Niroj
• 78,120 points
86 views
0 votes
1 answer

How to read environment variables in Node.js?

Hello @kartik, Yes,you can read environment variables in Node.js ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
131 views