Node - 如何运行 app.js? [英] Node - how to run app.js?
本文介绍了Node - 如何运行 app.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 Node.js
非常陌生,我尝试通过在终端 node app.js
中使用命令来运行一个项目(由其他开发人员制作).但是我遇到了下面的错误,你知道如何运行这个项目吗?
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.
错误日志如下:
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
推荐答案
假设我在机器上正确安装了 node 和 npm,我会
Assuming I have node and npm properly installed on the machine, I would
- 下载代码
- 导航到终端上的项目文件夹内部,我希望在那里看到 package.json 文件
- 执行 npm install 以安装所有项目依赖项
- 执行 npm install -g nodemon 以安装所有项目依赖项
- 然后 npm start OR node app.js OR nodemon app.js 让应用在本地主机上运行
- 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
希望这对某人有帮助
使用 nodemon app.js(nodemon 是一个实用程序,它将监视源中的任何更改并自动重新启动服务器)
use nodemon app.js ( nodemon is a utility that will monitor for any changes in your source and automatically restart your server)
这篇关于Node - 如何运行 app.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文