I'm trying to run a single script from my Heroku app. I'm trying to run it on the Heroku server with the following command:
heroku run node path/to/myScript.js
This script works perfectly when I run it locally. But I get an error when trying to run it remotely on Heroku.
I expect to see evidence the script ran correctly but instead I get the following error.
Error: Cannot find module 'puppeteer-cluster'
That dependency is located in my package.json
package.json "dependencies": {
...
"puppeteer-cluster": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/puppeteer-cluster/-/puppeteer-cluster-0.18.0.tgz",
"integrity": "sha512-xxxxxxxx+xxxxxxxxxxxxxxxxxxxxx==",
"requires": {
"debug": "^4.1.1"
}
},
...
What I have tried so far.
I tried to make sure I was committing all the new files to git correctly with the following.
git add . git commit -m "update" git push heroku master
I tried the following sequence of commands based on this SO answer.
$ heroku config:set NODE_MODULES_CACHE=false $ git commit -am 'disable_node_modules_cache' --allow-empty $ git push heroku master
I tried to rebuild and re-deploy my app from scratch as follows.
heroku create my-awesome-app --buildpack heroku/nodejs
But I got the error:
The name my-awesome-app is already taken
- This page lists the following, which I tried without success.
heroku config:set NODE_MODULES_CACHE=false
Next, you should ensure that you aren't accidentally checking your modules into git.
Finally, you should check to ensure that your dependencies are correctly listed in package.json.
I also tried double checking to make sure I'm not tracking any git files checking the following as suggested here.
git ls-files | grep node_modules
I added a node version to my package.json after checking the node version I have locally.
node --version v12.10.0
"name": "myapp",
"description": "a really cool app",
"version": "0.1.0",
"engines": {
"node": "12.10.0"
},
What am I doing wrong? And what should I try next?