2017-06-19 74 views
0

我已经在heroku上创建了免费帐户。我正在尝试在此上部署节点应用程序,但显示以下错误。错误:在Heroku服务器上部署节点应用程序时找不到模块'./formats'

2017-06-19T11:25:53.680527+00:00 app[web.1]: > [email protected] 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! [email protected] 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 [email protected] 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" 
    } 
} 

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

回答

1

就我而言,我的存储库中存在node_modules目录。我将它从github存储库中排除并再次部署。现在它正在工作

1

是的这个错误是由于你的情况下缺少的模块发生的错误:找不到模块'./formats'。您必须清理现有的node_modules目录并运行npm install 以新安装所有依赖项。如果你仍然在deployement面临的问题,那么请去通过这个链接,了解更多详细信息,

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

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

node_modules的

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

0

删除缓存和重新部署:

git rm -r --cached node_modules 

然后git push heroku master

您也可以禁用缓存,如果你不想缓存node_module而重新部署:

heroku config:set NODEMODULESCACHE=false 
git commit -am 'rebuild' --allow-empty 
git push heroku master 
heroku config:unset NODEMODULESCACHE 

这为我工作!

相关问题