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粉4652875922024-02-18 09:51:36
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), }), ] ... }