错误:找不到模块-在本地工作,但不能在Heroku上工作

时间:2019-06-24 15:41:05

标签: node.js heroku npm

我正在运行从Heroku容器克隆的节点应用程序。在本地运行,并且该应用程序从localhost:3000运行。

但是,当我使用git deploy将应用程序部署到heroku时,它会启动,然后立即崩溃。 heroku日志粘贴在下面。

我无法弄清楚为什么会出现此错误?

我试图更新npm,删除节点模块。

rm -rf node_modules
npm i core-util-is
npm install -g npm@latest

heroku日志如下:

2019-06-24T15:35:26.071317+00:00 app[web.1]: > node index.js
2019-06-24T15:35:26.071318+00:00 app[web.1]: 
2019-06-24T15:35:26.251019+00:00 app[web.1]: internal/modules/cjs/loader.js:638
2019-06-24T15:35:26.251023+00:00 app[web.1]:     throw err;
2019-06-24T15:35:26.251024+00:00 app[web.1]:     ^
2019-06-24T15:35:26.251026+00:00 app[web.1]: 
2019-06-24T15:35:26.251027+00:00 app[web.1]: Error: Cannot find module './putty'
2019-06-24T15:35:26.251031+00:00 app[web.1]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2019-06-24T15:35:26.251033+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2019-06-24T15:35:26.251034+00:00 app[web.1]:     at Module.require (internal/modules/cjs/loader.js:690:17)
2019-06-24T15:35:26.251036+00:00 app[web.1]:     at require (internal/modules/cjs/helpers.js:25:18)
2019-06-24T15:35:26.251037+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/sshpk/lib/formats/auto.js:18:13)
2019-06-24T15:35:26.251039+00:00 app[web.1]:     at Module._compile (internal/modules/cjs/loader.js:776:30)
2019-06-24T15:35:26.251040+00:00 app[web.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2019-06-24T15:35:26.251041+00:00 app[web.1]:     at Module.load (internal/modules/cjs/loader.js:653:32)
2019-06-24T15:35:26.251043+00:00 app[web.1]:     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-06-24T15:35:26.251044+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-06-24T15:35:26.259163+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-06-24T15:35:26.259707+00:00 app[web.1]: npm ERR! errno 1
2019-06-24T15:35:26.261454+00:00 app[web.1]: npm ERR! hello@1.0.0 start: `node index.js`
2019-06-24T15:35:26.261645+00:00 app[web.1]: npm ERR! Exit status 1
2019-06-24T15:35:26.261955+00:00 app[web.1]: npm ERR! 
2019-06-24T15:35:26.262153+00:00 app[web.1]: npm ERR! Failed at the hello@1.0.0 start script.
2019-06-24T15:35:26.262343+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-06-24T15:35:26.270567+00:00 app[web.1]: 
2019-06-24T15:35:26.270795+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-06-24T15:35:26.270955+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-06-24T15_35_26_264Z-debug.log

1 个答案:

答案 0 :(得分:0)

我已经删除了package.json和node_modules并运行

npm init

然后重新安装所需的软件包,现在可以使用了。