在我的本地计算机上,运行Node.js项目非常正常。但是,当我将应用程序部署到Heroku时,出现H10错误,并显示以下消息:
Error: Cannot find module './lib/websocket'
下面是我的package.json文件:
{
"name": "mazebattles",
"version": "1.0.0",
"description": "multiplayer maze competition",
"main": "server.js",
"scripts": {
"test": "node server.js"
},
"keywords": [
"mazes",
"multiplayer",
"game",
"race"
],
"author": "henryzhu",
"license": "ISC",
"dependencies": {
"easytimer.js": "^2.4.0",
"express": "^4.16.4",
"socket.io": "^2.2.0",
"socketio": "^1.0.0",
"uniqid": "^5.0.3"
},
"devDependencies": {
"@babel/preset-env": "^7.4.2",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1"
},
"engines": {
"node": "10.13.0"
}
}
答案 0 :(得分:0)
当依赖项存在于devDependencies中时,我就遇到了这个问题。您的堆栈跟踪应该会有所帮助,并且您可以找出要查看的模块。
答案 1 :(得分:0)
我通过不部署node_modules解决了该错误。显然,Heroku会自动为您部署node_modules。