尝试将项目推送到 heroku - 在使用 heroku-cli 和连接到 Github 时遇到相同的错误。
错误日志:
-----> Building dependencies
Installing node modules (package.json + package-lock)
npm ERR! Cannot read property 'match' of undefined
包.json
{
"name": "myApp",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.3",
"react-social-icons": "^4.1.0",
"react-spring": "^7.2.10"
},
...
"eslintConfig": {
"extends": "react-app"
},
"engines": {
"node": "10.13.0"
},
...
"devDependencies": {
"react": "^16.7.0"
}
}
React 最初并不在 devDependencies 中 - 将其作为修复早期错误的尝试。
无论哪种方式,问题仍然存在。
最佳答案
我遇到了同样的问题,但是上面提到的解决方案都不适合我,我什至尝试使用 heroku-repo 插件清理我的远程仓库,顺便说一下,您可以使用 安装。 heroku 插件:安装 heroku-repo 其次是 heroku repo:reset -a appname 试试这个。
对我有用的解决方案是从 heroku 禁用 node_modules 缓存。 Heroku 维护一个缓存目录,该目录在构建之间保持不变。该缓存用于存储 npm、yarn 和 bower 的缓存。
尝试使用以下步骤。
关于heroku - 在推送到 heroku 时无法读取未定义的属性 'match',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54410071/