Why can you get process.env, using node in cmd but not process.env content in node in vue development?

just take the development environment as an example

I saw this line of code in webpack.dev.conf.js,

new webpack.DefinePlugin({
      "process.env": require("../config/dev.env")
    }),

if I have this line of code, I can get the content configured in config/dev.env.js in vue.

if I comment out this line of code, I get process.env as a {} empty object,

but shouldn"t process.env in node be an environment variable in the system

process  Node.js   require()

since I commented out that line of code, it means I didn"t overwrite its value, so why did I get an empty object instead of the environment variable in the current operating system?


vue runs on the browser side, while process is on the node side, so you can use process, in the process of packaging and compilation based on node instead of using it alone in vue


similar questions have been asked in sef , you can refer to https://codeshelper.com/q/1010000017204576


is like this. Vue runs on web, and there is no variable of node or api (including process )

.

makes the api of node valid on the web side through the configuration of module.exports.node of webpack.base.config.js , so there is no environment variable corresponding to process.env on the web side, just an empty object, so it is convenient to mount NODE_ENV

of the production environment or the development environment.
Menu