vike: Vike 0.4.161 `process.env.NODE_ENV` hard convention is problematic

Description

Vike 0.4.161 breaks whole NX monorepo. None of my projects works. Even the NX VSCode plugin stops working.

The error message is:

Inner Error: Error: [vike][Wrong Usage] The environment is set to be a development environment by process.env.NODE_ENV === “development” which is forbidden upon building, see https://vike.dev/NODE_ENV

Reproduction:
https://github.com/marviobezerra/vike-nx

pnpm i
pnpm nx run vikedemo:serve

Workaround:

Downgrade to vike@0.4.160

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 23 (12 by maintainers)

Commits related to this issue

Most upvoted comments

In summary, the analysis report fails and it blocks our deployment based on the ISO certifications that we are contractually obliged to maintain. So that is a critical issue based on our business model.

These certifications also include code warnings. It’s a very complex topic, bear with me.

In summary, we have 3 to 7 releases to fix the warnings. How many releases depending on the Sonarqube warning level. So, a warning now will eventually escalate to a critical issue and block our deployment.

Our certifications also check package versions. It defines if we must  update based https://semver.org. I’m mentioning that because right now, we downgraded Vike to unblock our deploy, but we will need to update it soon.

We opened a Sonarqube ticket when we had issues with Vite and their answer was “Fix Vite, by creating a fork, or choose another bundling tool”.

They hold the power and it sucks but we need to deliver.

I’m getting the same error message but in my case I’m using Sonarqube for static code analysis.

We don’t set environment variables anywhere in our code, however, what happens inside of Sonarqube is outside of our control. We use Sonarqube as SaaS for ISO certifications, so the configurations are very restricted.

We faced a similar issue with Vite, but to remove a warning, and solution was to set VITE_USER_NODE_ENV, kind of what was proposed above.

Check https://github.com/vitejs/vite/blob/76f30ae23b92f9af910ec02d98e2baaefa12141f/packages/vite/src/node/config.ts#L559

Is it possible to revert it back?

Further polished https://vike.dev/NODE_ENV. I also thought it through again, and I still believe that how Vike’s handling this is the correct way.

Again, as I already said in my previous reply, I’m open to make it a warning again.

As for path aliases, you seem to have missed my latest replies in the conversation: I already changed my mind on that.

Please dig into why your Nx setup is broken and report back. It isn’t my job to dig into your broken setup.

And, to be clear, I will revert and make it a warning instead of an error if it turns out to be a blocker.