Production deploy fails when branch deploy succeeds

In distracted-saha-1575e4:

the branch deploy completes successfully and logs end with site is live

the production deploy fails because webpack (the code bundler) Cannot find module 'extract-css-chunks-webpack-plugin'

The problem is that each is exactly the same code, exactly the same commit. Literally, this is the HEAD, wherein master is the production branch and feature/svelte is the branch that deploys successfully: commit b4a1368fb17f115e49712f3a79541cf7fe3fde5e (HEAD -> master, origin/master, origin/feature/svelte, feature/svelte)

Needless to say, the missing module is in the package manifest package.json

Is there is some difference in the environment between the two that I should be aware of?

Update: I cleared the cache and redeployed the failing build. Now it’s failing for a different, but similar, reason: the environment cannot find a package that is definitely in the manifest.

(in this case it’s rimraf, platform-neutral node command that removes directories)

12:33:12 PM: > rimraf public && rimraf functions
12:33:12 PM: sh: 1: rimraf: not found

(I deleted an earlier question “Branch Deploy” versus “Deploy Preview” because I was conflating this specific issue with another one. My apologies to @futuregerald who answered there. I never did get to see your answer!)

Ah ha! I deleted the cache on the successful deploy and that fails with the same error!

The difference between the environments was that the production branch had a different cache.

The question now is why? Why isn’t npm install pulling those missing modules?

… and I redeployed this failed deploy, and rimraf now works but we’re back to the previous error of the missing webpack plugin.

I finally succeeded, but I’m not sure why it worked. I moved the category of some of the packages in the manifest from "devDependencies" to "dependencies" and then the build process completed.

I’ll need to do some more searching about why it happened, but I’ll leave this here in case anyone in the future has this kind of issue.

thanks for providing the rundown, rendall! I am wondering if maybe moving the dependencies from one section to another maybe forced a package update which solved a problem we weren’t aware of ? :thinking:

1 Like

Two months later, and I finally understand what was going on!

If NODE_ENV is set to production then npm will not install anything in devDependencies

I feel like a dufus, but maybe this will help someone as baffled as I was

From the npm-install docs:

With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies . To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production , you can use --production=false .

1 Like

Thanks for taking the time to follow up! Super appreciate your help in leaving breadcrumbs for future answer-seekers :slight_smile:

1 Like

Always! It’s only polite. :slight_smile:

1 Like