My goal is to set a BACKEND environment variable in order for our VueJS project to communicate with the API hosted there, but I keep receiving an error message saying Unexpected token :
.
Here is the current code snippet from our config/dev.env.js
, and I'm currently stuck at this point
module.exports = {
NODE_ENV: '"development"',
HOST: process.env.BACKEND,
NAME: '"Jaguar Dashboard"'
}
All I want is for the process.env.BACKEND to be assigned a value like 'http://example.com' so that our VueJS project can function properly. How can I resolve this issue?
UPDATE
I was able to make it work by modifying the code as follows:
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
HOST: 'http://example-0e1b-4a12-91ef-b853a47bab34.node.dockerapp.io:8000',
NAME: 'Jaguar Dashboard'
})
When attempting JSON.stringify(process.env)
, an error(Unexpected identifier
) occurs in this line:
[...]
When using '"'+process.env.BACKEND+'"'
, the same error(Unexpected identifier
) arises in this line:
[...]
However, when I simply define a string as mentioned above, the code executes without any issues as shown below:
[...]
SCREENSHOTS OF THE CODES:
config/dev.env.js
https://i.stack.imgur.com/LoyQq.png
build/webpack.base.conf.js
https://i.stack.imgur.com/PAF4n.png
build/webpack.dev.conf.js
https://i.stack.imgur.com/t8RDF.png
P.S.
The errors mentioned above occur during the execution of npm run dev
in our VueJS project