我刚刚整理了我的第一个Express应用程序。我可以使用(SELECT virtuemart_product_id
FROM #__virtuemart_product_badges
WHERE badge = 3)
UNION
SELECT virtuemart_product_id
FROM #__virtuemart_products
WHERE product_special = 1
来运行服务器而没有问题,但是当我尝试使用node server.js
脚本(似乎是Heroku所需要的)时,出现以下错误。与类似的问题不同,其中所讨论的模块似乎是一个程序包,我看不到所指的是“模块”。我尝试删除start
和npm
,npm-cache
等。
操作系统: Windows 8.1
节点: v8.11.3
NPM: v5.6.0
node-modules
我的Error: Cannot find module 'C:\Users\Derek\Documents\Cloud\Projects\2018-2019\NodeTest\example-server\server.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example-server@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example-server@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Derek\AppData\Roaming\npm-cache\_logs\2018-09-09T07_27_10_7
14Z-debug.log
:
package.json
项目结构:
{
"name": "example-server",
"version": "1.0.0",
"main": "src/server.js",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"body-parser": "^1.18.3",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"firebase-admin": "^6.0.0",
"pg": "^7.4.3"
}
}
这是日志文件的输出:
example-server
└───node_modules
└───src
│ └───server.js
│
└───package.json
我的意思不是只是将错误转储到这里,但是我对Node还是很陌生,并且花了几个小时谷歌搜索都无济于事。
答案 0 :(得分:4)
server.js
中"start": "node server.js"
的文件路径错误
尝试:"start": "node src/server.js"