MERN-heroku-postbuild-客户端依赖项错误(create-react-app)

时间:2019-07-01 13:16:35

标签: node.js reactjs heroku npm mern

错误(运行 heroku-postbuild 脚本时)

Creating an optimized production build... Failed to compile.

   ./src/index.js
   Error: Cannot find module 'eslint'
   Referenced from:

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! react-shop-app-client@0.1.0 build:反应脚本构建 npm ERR! Exit status 1

大家好, 使用Heroku构建React(MERN)应用时遇到问题。

“ npm install” 可以在服务器目录和客户端(create-react-app)目录中正常使用,一切都很好。 “ npm build” 命令在客户端(create-react-app)目录中也很好用。

问题是,当我想将我的应用程序部署到Heroku并使用heroku-postbuild脚本时。然后我收到一个关于“ eslint”依赖项的错误。我找到了一个解决方案,只需将“ eslint”作为devDependency添加到我的客户端package.json中即可。这使我的heroku-postbuild脚本运行良好。

不幸的是,然后,当我想在本地主机上运行我的应用程序时,我得到了关于eslint版本的错误,因为我不应该更改create-react-app默认软件包的版本,所以我有点困惑如何真正解决这个问题。

我的package.json脚本:

"scripts": { "client-install": "npm install --prefix client", "start": "node server.js", "server": "nodemon server.js", "client": "npm start --prefix client", "dev": "concurrently \"npm run server\" \"npm run client\"" },

到---> LINK is HERE

的链接到我有问题的存储库

有人对此有解决方案吗?

0 个答案:

没有答案