Install it by running: JavaScript

Dive into business data optimization and best practices.
Post Reply
hasinam2206
Posts: 18
Joined: Sun Dec 22, 2024 3:50 am

Install it by running: JavaScript

Post by hasinam2206 »

You can thus execute: JavaScript Copy the code npm run start:dev If you want to know more about node-env-run, check out its documentation. Environment variables and npm scripts In some scenarios, it is useful to check the value of an environment variable before entering the Node.

js application in npm scripts. For example, if 11-digit phone number format philippines you want to use node-env-run when you are in a development environment, but node when you are in production mode. To do this, use the if-env tool . Copy the code npm install if-env --save However, make sure you don't install it as a "development dependency" as we will need it in production as well.

Image

Now edit your npm scripts in your package.json : JavaScript Copy the code "scripts": { "start": "if-env NODE_ENV=production ?? npm run start:prod || npm run start:dev", "start:dev": "nodenv -f .", "start:prod": "node ." } This script will now run npm run start:prod, then node. If NODE_ENV is set to production, it will run npm run start:dev, then nodenv -.
Post Reply