npm run build --mode [.env.mode] not working as expected
See original GitHub issueVersion
3.0.0-beta.16
Reproduction link
https://codesandbox.io/s/qlx254n09j
Steps to reproduce
- Create
.env.staging
file in the root - Add key pairs
NODE_ENV=production
andVUE_APP_ENV=staging
in the file - Add script to package.json
"staging":"vue-cli-service build --mode staging",
- Run
npm run build --mode staging
- Run
npm run staging
What is expected?
Case 1
npm run buid --mode staging
gives a production oriented build with staging variables
Case 2
npm run staging
gives a production oriented build with staging variables
What is actually happening?
Case 1
It gives a production oriented build with production variables
Case 2
It gives a development oriented build with staging variables
I need this to deploy this to Heroku. CD/CI. I’m using postinstall
script to build production
, dev
or staging
servers based on the APP_VUE_ENV
variable. Please help me. I’m super excited with Vue so far!
Reference:
https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode https://github.com/vuejs/vue-cli/issues/948 https://forum.vuejs.org/t/how-to-build-production-app-with-varying-config/29708
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
npm run build --mode [.env.mode] not working as expected
As expected, running the command npm run build --mode staging is to give a production build with variable as listed in the .env.staging...
Read more >Vue.js – npm run build –mode [.env.mode] not working as expected ...
What I've done so far: I've been trying to setup multiple build modes like staging , testing , production and development based on...
Read more >npm run build --mode [.env.mode] not working as expected ...
I was having the same problem, I figured out my problem was from using a beta version ( 3.0.0-beta.9 ) of @vue/cli-service so...
Read more >Create-react-app environments - Medium
env file. The value of NODE_ENV is set automatically to development (when using npm start ), test (when using npm test ) ...
Read more >cross-env - npm
Run scripts that set and use environment variables across platforms. NOTICE: cross-env still works well, but is in maintenance mode.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is related to how npm passes arguments to scripts when using
npm run
In other words: all arguments before
--
are interpreted as arguments for npm itself, not the script you are running.This seems to be a regression introduced in #1503