2

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

Uncaught ReferenceError: process is not defined

It's using the webpack and run by npm start command.

1 Answer 1

1

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),
      }),
   ]
   ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.