当前位置:网站首页>process.env
process.env
2022-07-25 20:27:00 【View the mountains】
process.env
.
brief introduction
process.env yes Node.js An environment object in . It holds the variable information of the system's environment . You can use Node.js The command line tool can directly view .process.env Property returns an object , Contains the current Shell All environment variables of . Simply put, you are configuring the file package.json To configure webpack All environment variables can be passed through process.env To get to the
such as ,process.env.HOME Return the user's home directory . NODE_ENV Is one of the environment variables . This variable is mainly used to identify the current environment ( Production environment , development environment ). By default, there is no environment variable , Manual configuration required .
Example
Variables added to the startup command can be passed process.env To get
// An highlighted block
"scripts": {
"dev": "vue-cli-service serve",
"dev:test": "cross-env VUE_APP_TARGET=http://172.16.200.225:8080/mes-api vue-cli-service serve",
"dev:prot": "cross-env VUE_APP_BRANCH=port VUE_APP_TARGET=http://172.16.200.225:8081/mes-api vue-cli-service serve",
},
Use cross-env
stay webpack In the project , We can set package.json To achieve , however Windows Systems and Mac The system is different .
//windows System
"scripts": {
"dev": "vue-cli-service serve",
"dev:test": "set VUE_APP_TARGET=http://172.16.200.225:8080/mes-api vue-cli-service serve",
"dev:prot": "set VUE_APP_BRANCH=port VUE_APP_TARGET=http://172.16.200.225:8081/mes-api vue-cli-service serve",
},
//mac System
{
"scripts": {
"dev": "export NODE_ENV=development && webpack-dev-server --open --hot",
"build": "export NODE_ENV=production && --progress --hide-modules"
}
}
So here comes the question , I am here Windows Develop deployed projects , May be in Mac The system cannot package normally , vice versa . To solve this problem , Someone developed cross-env.
cross-env It is a third-party package for setting environment variables across platforms , It allows you to configure only one line of commands , You can easily set environment variables on multiple platforms . Install first , Then configure package.json
npm install --save-dev cross-env
// package.json
{
...
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --mode=production --progress --hide-modules"
},
}
Original blog address :https://blog.csdn.net/qq_44376306/article/details/122554570
边栏推荐
- RF、GBDT、XGboost特征选择方法「建议收藏」
- Redis source code -ziplist
- Share 25 useful JS single line codes
- Kubernetes advanced part learning notes
- 移动web布局方法
- [onnx] export pytorch model to onnx format: support multi parameter and dynamic input
- 「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
- 【高等数学】【1】函数、极限、连续
- 网络协议:TCP Part2
- 从底层结构开始学习FPGA(16)----PLL/MMCM IP的定制与测试
猜你喜欢

【高等数学】【6】多元函数微分学

JVM (XXIII) -- JVM runtime parameters

JMeter - interface test

【云原生 | 从零开始学Kubernetes】八、命名空间资源配额以及标签

雷达水位计的工作原理及安装维护注意事项
![[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
![[onnx] export pytorch model to onnx format: support multi parameter and dynamic input](/img/bd/e9a1d3a2c9343b75dbae5c7e18a87b.png)
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input

Docker 搭建 Redis Cluster集群

毕业从事弱电3个月,我为什么会选择转行网络工程师

Share 25 useful JS single line codes
随机推荐
Go language go language built-in container
JS作用域与作用域链
Kubernetes进阶部分学习笔记
CarSim simulation quick start (16) - ADAS sensor objects of CarSim sensor simulation (2)
股票软件开发
Increase swap space
Advantages of network virtualization of various manufacturers
Arrow parquet
Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks
各厂商网络虚拟化的优势
Link list of sword finger offer question bank summary (III) (C language version)
[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
【高等数学】【6】多元函数微分学
「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
MySQL 日期【加号/+】条件筛选问题
智能电子界桩自然保护区远程监控解决方案
Application of conductive slip ring in mechanical equipment
Introduction and construction of consul Registration Center