Undefined procedure in Vue.js
P粉387108772
P粉387108772 2024-02-17 10:45:31
0
1
417

I try to use process.env.process.env.VUE_APP_SERVER_URL in my vue project. But I got the following error.

Uncaught ReferenceError: process is not defined

It uses webpack and is run via the npm start command.

Once you know the solution, please feel free to contact me.

P粉387108772
P粉387108772

reply all(1)
P粉465287592

You can add the following code in webpack.config.js.

const webpack = require('webpack');
const dotenv = require('dotenv').config({ path: __dirname + '/.env' })

module.exports = {
   ...
   plugins: [
      new webpack.DefinePlugin({
          'process.env': JSON.stringify(dotenv.parsed),
      }),
   ]
   ...
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template