在Heroku上部署Next.js应用程序时出现npm错误

时间:2019-05-08 16:18:28

标签: heroku next.js

我正在尝试在heroku上部署Next.js应用程序,但是在项目构建过程中,它给出错误“ npm ERR!path / tmp / build_e888593abeb04bd0ba3c83c3147db89b / node_modules / websocket”

我找到了一个解决方案,说要从node_modules / websocket目录中删除.git文件夹。但是上述目录中没有.git文件夹。

   npm ERR! path /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket
   npm ERR! code EISGIT
   npm ERR! git /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket: Appears to be a git repo or submodule.
   npm ERR! git     /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket
   npm ERR! git Refusing to remove it. Update manually,
   npm ERR! git or move it out of the way first.

   npm ERR! A complete log of this run can be found in:
   npm ERR!     /tmp/npmcache.mTr1h/_logs/2019-05-08T16_02_03_118Z-debug.log

1 个答案:

答案 0 :(得分:0)

1)运行heroku run bash进入bash终端,您可以在其中访问项目的文件

2)然后rm -rf node_modules完全删除node_modules目录。

3)退出bash。

4)运行heroku config:set NODE_MODULES_CACHE=false,以确保Heroku在重建node_modules时不会尝试使用缓存。

如果此操作得以解决,则应将node_modules_cache设置回true

相关问题