nuxt-community / moment-module

Efficient Moment.js integration for Nuxt
MIT License
195 stars 12 forks source link

Cannot find module `moment` #79

Open IgnisDa opened 3 years ago

IgnisDa commented 3 years ago

I encountered this problem while deploying my nuxt app to Heroku. My app has a dependency on this module. I have target: 'server' set in my nuxt.config.js.

The solution was pretty simple. The installation instructions say that you have to install this dependency as a development one. But that works only for nuxt apps that have target: 'static' set in their nuxt.config.js.

I feel this should be mentioned in the installation instructions for the module

Chrisimir commented 2 years ago

I experienced this same issue. It seems to be due to automatic pruning of devDependencies in the buildpack.

From Heroku troubleshooting:

In order create a smaller slug size for apps, the buildpack will prune out the devDependencies from the package.json at the end of the build, so that the slug will only include the dependencies that are listed at runtime. If there is a dependency that is in the devDependencies that is needed after the prune occurs, move the dependency to dependencies, so it is not removed.

So to fix it you can either move the devDependencies to dependencies or turn off pruning of devDependencies with NPM: heroku config:set NPM_CONFIG_PRODUCTION=false YARN: heroku config:set YARN_PRODUCTION=false