Home  >  Q&A  >  body text

Undefined procedure in Vue.js

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粉387108772P粉387108772244 days ago357

reply all(1)I'll reply

  • P粉465287592

    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),
          }),
       ]
       ...
    }

    reply
    0
  • Cancelreply