gpt4 book ai didi

node.js - 错误: Cannot find module './formats' when deploying node app on heroku server

转载 作者:太空宇宙 更新时间:2023-11-03 22:45:50 25 4
gpt4 key购买 nike

我已经在 heroku 上创建了免费帐户。我正在尝试在此部署 Node 应用程序,但这显示以下错误。

2017-06-19T11:25:53.680527+00:00 app[web.1]: > mypu@1.0.0 start /app
2017-06-19T11:25:53.680528+00:00 app[web.1]: > node server.js
2017-06-19T11:25:53.680528+00:00 app[web.1]:
2017-06-19T11:25:53.862204+00:00 app[web.1]: module.js:471
2017-06-19T11:25:53.862207+00:00 app[web.1]: throw err;
2017-06-19T11:25:53.862208+00:00 app[web.1]: ^
2017-06-19T11:25:53.862209+00:00 app[web.1]:
2017-06-19T11:25:53.862210+00:00 app[web.1]: Error: Cannot find module './formats'
2017-06-19T11:25:53.862211+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-06-19T11:25:53.862212+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-06-19T11:25:53.862212+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-06-19T11:25:53.862213+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-06-19T11:25:53.862229+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/qs/lib/stringify.js:4:15)
2017-06-19T11:25:53.862230+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-06-19T11:25:53.862231+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-06-19T11:25:53.862231+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-06-19T11:25:53.862232+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-06-19T11:25:53.862233+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-06-19T11:25:53.872899+00:00 app[web.1]:
2017-06-19T11:25:53.886139+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-06-19T11:25:53.886419+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-06-19T11:25:53.886602+00:00 app[web.1]: npm ERR! node v6.11.0
2017-06-19T11:25:53.886778+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-06-19T11:25:53.886955+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-06-19T11:25:53.887988+00:00 app[web.1]: npm ERR! mypu@1.0.0 start: `node server.js`
2017-06-19T11:25:53.888109+00:00 app[web.1]: npm ERR! Exit status 1
2017-06-19T11:25:53.888249+00:00 app[web.1]: npm ERR!
2017-06-19T11:25:53.888373+00:00 app[web.1]: npm ERR! Failed at the mypu@1.0.0 start script 'node server.js'.
2017-06-19T11:25:53.888490+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-06-19T11:25:53.888603+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the mypu package,
2017-06-19T11:25:53.888719+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-19T11:25:53.889463+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-19T11:25:53.889583+00:00 app[web.1]: npm ERR! node server.js
2017-06-19T11:25:53.889701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-19T11:25:53.889807+00:00 app[web.1]: npm ERR! npm bugs mypu
2017-06-19T11:25:53.890108+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-19T11:25:53.890263+00:00 app[web.1]: npm ERR! npm owner ls mypu
2017-06-19T11:25:53.890433+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-06-19T11:25:53.898834+00:00 app[web.1]:
2017-06-19T11:25:53.899088+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-06-19T11:25:53.899216+00:00 app[web.1]: npm ERR! /app/npm-debug.log
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-06-19T11:25:53.888719+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-19T11:25:53.889463+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-19T11:25:53.889583+00:00 app[web.1]: npm ERR! node server.js
2017-06-19T11:25:53.889701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-19T11:25:53.889807+00:00 app[web.1]: npm ERR! npm bugs mypu
2017-06-19T11:25:53.890108+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-19T11:25:53.890263+00:00 app[web.1]: npm ERR! npm owner ls mypu
2017-06-19T11:25:53.890433+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-06-19T11:25:53.898834+00:00 app[web.1]:
2017-06-19T11:25:53.899088+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-06-19T11:25:53.899216+00:00 app[web.1]: npm ERR! /app/npm-debug.log
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-06-19T11:25:53.888719+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-19T11:25:53.889463+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-19T11:25:53.889583+00:00 app[web.1]: npm ERR! node server.js
2017-06-19T11:25:53.889701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-19T11:25:53.889807+00:00 app[web.1]: npm ERR! npm bugs mypu
2017-06-19T11:25:53.890108+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-19T11:25:53.890263+00:00 app[web.1]: npm ERR! npm owner ls mypu
2017-06-19T11:25:53.890433+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-06-19T11:25:53.898834+00:00 app[web.1]:
2017-06-19T11:25:53.899088+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-06-19T11:25:53.899216+00:00 app[web.1]: npm ERR! /app/npm-debug.log
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-06-19T11:25:53.888719+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-19T11:25:53.889463+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-19T11:25:53.889583+00:00 app[web.1]: npm ERR! node server.js
2017-06-19T11:25:53.889701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-19T11:25:53.889807+00:00 app[web.1]: npm ERR! npm bugs mypu
2017-06-19T11:25:53.890108+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-19T11:25:53.890263+00:00 app[web.1]: npm ERR! npm owner ls mypu
2017-06-19T11:25:53.890433+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-06-19T11:25:53.898834+00:00 app[web.1]:
2017-06-19T11:25:53.899088+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-06-19T11:25:53.899216+00:00 app[web.1]: npm ERR! /app/npm-debug.log
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-06-19T11:25:53.888719+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-19T11:25:53.889463+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-19T11:25:53.889583+00:00 app[web.1]: npm ERR! node server.js
2017-06-19T11:25:53.889701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-19T11:25:53.889807+00:00 app[web.1]: npm ERR! npm bugs mypu
2017-06-19T11:25:53.890108+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-19T11:25:53.890263+00:00 app[web.1]: npm ERR! npm owner ls mypu
2017-06-19T11:25:53.890433+00:00 app[web.1]: npm ERR! There is likely additional logging output above.

相同的应用程序在我的本地计算机上运行良好。这是package.json

{
"name": "mypu",
"version": "1.0.0",
"description": "mypu",
"main": "index.js",
"scripts": {
"start" : "node server.js"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"body-parser": "^1.15.0",
"connect-timeout": "^1.8.0",
"express": "^4.13.4",
"generic-pool": "^2.4.2",
"log4js": "^1.1.1",
"multer": "^1.2.0",
"mysql": "^2.10.2",
"requestify": "^0.1.17"
}
}

可能是什么问题?我错过了什么吗?

最佳答案

是的,这个错误是由于缺少模块而发生的,就像您的情况一样错误:找不到模块“./formats”。您必须清理现有的 node_modules 目录并运行 npm install全新安装所有依赖项。如果您在部署中仍然遇到问题,请通过此链接了解更多详细信息

https://devcenter.heroku.com/articles/deploying-nodejs

https://scotch.io/tutorials/how-to-deploy-a-node-js-app-to-heroku

https://www.youtube.com/watch?v=6Fu39V6T_G0

关于node.js - 错误: Cannot find module './formats' when deploying node app on heroku server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44629501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com