Cannot read property 'match' on undefined on pushing to heroku
Asked Answered
C

4

7

Tried pushing a project to heroku - got the same error when using heroku-cli and when connecting to Github.

Error Log:

-----> Building dependencies

       Installing node modules (package.json + package-lock)

       npm ERR! Cannot read property 'match' of undefined

Package.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 wasn't initially in devDependencies - have that there as an attempt at fixing an earlier error.

Issue persists either way.

Capitalist answered 28/1, 2019 at 20:48 Comment(0)
G
4

Check package-lock.json

This issue is most likely related to your package-lock.json. This file causes a lot of issues, but it's recommended that you check it into source.

With that said, one of two things should fix your issue:

  1. First try deleting your package-lock.json and node_modules locally, then re-install all of your dependencies: npm i. Try pushing to Heroku again after this is complete.
  2. If the suggestion above does not work, just delete your package-lock.json file locally, commit your change, and try pushing to Heroku again.

Also, you should not have to list react as a dev dependency. You can delete that from your package.json.

Gaynellegayner answered 28/1, 2019 at 21:2 Comment(3)
Thanks Don! Pushing to heroku without package-lock.json got things up and running! :)Capitalist
@Capitalist np. Please make sure to accept my answer if it helped you solve your problem.Gaynellegayner
Simply deleting package-lock.json, committing changes and then re-attempting deploy, also worked for me. I'd suggest making that option #1. Since this is a remote deploy, how would deleting node_modules locally help at all?Describe
A
15

I had this same issue, however none of the solutions mentioned above worked for me, I even tried to clean my remote repo, using heroku-repo plugin which by the way you can install using heroku plugins:install heroku-repo followed by heroku repo:reset -a appname to try luck with this one.

The solutions which worked for me was to disable the node_modules cache from heroku. Heroku maintains a cache directory that is persisted between builds. This cache is used to store caches for npm, yarn, and bower.

Try using the following steps.

  1. heroku config:set NODE_MODULES_CACHE=false
  2. now push again with - git push heroku master
Adventuresome answered 16/2, 2020 at 17:16 Comment(2)
solution worked for me. So many answers said to delete package_lock but I never pushed it to master. the p lock is in my git ignore so I knew it had to be a caching bug and when I uninstalled an old module that must have been the problem. thank you :)Heimdall
Fixed for me also. Probably should be the accepted answer.Selry
G
4

Check package-lock.json

This issue is most likely related to your package-lock.json. This file causes a lot of issues, but it's recommended that you check it into source.

With that said, one of two things should fix your issue:

  1. First try deleting your package-lock.json and node_modules locally, then re-install all of your dependencies: npm i. Try pushing to Heroku again after this is complete.
  2. If the suggestion above does not work, just delete your package-lock.json file locally, commit your change, and try pushing to Heroku again.

Also, you should not have to list react as a dev dependency. You can delete that from your package.json.

Gaynellegayner answered 28/1, 2019 at 21:2 Comment(3)
Thanks Don! Pushing to heroku without package-lock.json got things up and running! :)Capitalist
@Capitalist np. Please make sure to accept my answer if it helped you solve your problem.Gaynellegayner
Simply deleting package-lock.json, committing changes and then re-attempting deploy, also worked for me. I'd suggest making that option #1. Since this is a remote deploy, how would deleting node_modules locally help at all?Describe
V
2

You may want to do this heroku config:set NODE_MODULES_CACHE=false from your terminal. It was what worked for us for this same error.

Vincentia answered 20/3, 2020 at 13:42 Comment(0)
B
0

just remove lock file and try again it will work.

Bascomb answered 26/11, 2019 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.