Heroku deploy failure for Strapi because of an unresolved module

System Information
  • Strapi Version: 3.6.3
  • Operating System: macOS Monterey 12.0.1
  • Database: Postgres
  • Node Version: 12.22.7
  • NPM Version: 6.14.15
  • Yarn Version:

When I launch git push heroku master the Strapi (3.6.3) build works until it encounters a plugin and then it outputs:

Error: Module not found: Error: Can't resolve 'react-geolocated' in etc

This plugin is made by me and it is not included as dependency in the package.json on the root dir.

But package.json is correct and local build it works.

Runtime environment:

remote.        NPM_CONFIG_PRODUCTION=false
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        YARN_PRODUCTION=false
remote:        USE_NPM_INSTALL=false
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=false

node v.12.22.7 is used both locally and remotely.

What node/npm version is heroku installing?

v.12.22.7 / 6.14.15 both locally and remotely but I suppose the problem is that Heroku will never launch npm install on a custom plugin that is not added to the main package.json as dependency…

Yes that’s true, if it’s a local plugin then you need to put the modules in the main package.json

Thanks! There is an alternative, keeping the module in its own package.json? Maybe deploying the node_modules folder of the plugin?

Yes but instead of placing it in plugins you need to create a custom folder like packages and reference the package in your core package.json like "your-custom-package": "file:packages/your-custom-package"

Given anytime you change it locally you have to rerun an npm install or yarn install so it’s not ideal.

Or you publish it to NPM and use it like a regular package

1 Like

Yes but instead of placing it in plugins you need to create a custom folder like packages and reference the package in your core package.json like "your-custom-package": "file:packages/your-custom-package"

I think this can be an acceptable solution, thanks!