I'm trying to add environment variable inside .env
file in my nuxt project.
My Nuxt.js version is 2.15.3
Here is a snippet from my nuxt.config.js
:
export default {
publicRuntimeConfig: {
baseURL: process.env.BASE_URL
},
ssr: false,
target: 'static',
}
Here is my .env
file:
BASE_URL=https://my-url.smth
But when I run npm run dev
then nuxt gives error:
ERROR in ./.env 1:14 Module parse failed: Unexpected token (1:14) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
I was guided by this article https://nuxtjs.org/tutorials/moving-from-nuxtjs-dotenv-to-runtime-config/
Also it DOES NOT work with the old way through the @nuxtjs/dotenv
.