I changed my code to use process.env and the build fails (Parcel.js)

I refactored my code to use process.env and env variables instead of hardcoding the front end and back end URLs, but the build keeps failing now. this is the readout:
7:16:00 PM: ❯ Current directory
7:16:00 PM: /opt/build/repo
7:16:00 PM: ​
7:16:00 PM: ❯ Config file
7:16:00 PM: No config file was defined: using default values.
7:16:00 PM: ​
7:16:00 PM: ❯ Context
7:16:00 PM: production
7:16:00 PM: ​
7:16:00 PM: 1. Build command from Netlify app
7:16:00 PM: ────────────────────────────────────────────────────────────────
7:16:00 PM: ​
7:16:00 PM: $ CI= npm run build
7:16:00 PM: > client@1.0.0 build
7:16:02 PM: > parcel build ./*.html

:rotating_light: /opt/build/repo/landing.html:undefined:undefined: plugin is not a function
7:16:02 PM: at LazyResult.run (/opt/build/repo/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:288:14)
7:16:02 PM: at LazyResult.asyncTick (/opt/build/repo/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:212:26)
7:16:02 PM: at /opt/build/repo/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:254:14
7:16:02 PM: at new Promise ()
7:16:02 PM: at LazyResult.async (/opt/build/repo/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:250:23)
7:16:02 PM: at LazyResult.then (/opt/build/repo/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:131:17)
7:16:02 PM: ​
7:16:02 PM: “build.command” failed
7:16:02 PM: ────────────────────────────

7:16:02 PM: ​
7:16:02 PM: Error message
7:16:02 PM: Command failed with exit code 1: CI= npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
7:16:02 PM: ​
7:16:02 PM: Error location
7:16:02 PM: In Build command from Netlify app:
7:16:03 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
7:16:02 PM: CI= npm run build

Hi there @breddy49, :wave:t6: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console

Hi Sam!
I’ve tried several of the debugging procedures in the documentation, but unfortunately it looks like I haven’t stumbled on the solution yet :sweat_smile:
this is my site: silly-salmiakki-307386
As mentioned, this page was built with Parcel and was working fine when I hardcoded the Front-end Netlify and Back-end Render URLS. However, once I refactored to use process.env the builds started failing (while they still work locally).
I’ve tried adding CI=" " to the start of my build command, which didn’t work. I’ve tried different environment configuration variables which hasn’t worked either. I also deprecated my Parcel to a previous version, but that didn’t help either. I’m sure there is a solution for this, but I haven’t been able to find it - apologies, I’m a newbie at deploying to prod.

Appreciate your help.

Resolved. It appears this was a case sensitivity issue with the filenames. After making sure all filenames in the parcel build entry points were lowercase, I was able to successfully publish the site again. Oddly enough, this was not an issue before I moved to environment variables.

1 Like

thanks so much for coming back and letting us know you solved your issue