I'm having issues getting dotenv to use the .env.development.local
or .env.development
file when starting in development mode. It only ever uses .env
.
My package.json:
{
"name": "server",
"version": "1.0.0",
"description": "",
"scripts": {
"build": "webpack",
"start": "nodemon src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"babel-loader": "^9.1.2",
"copy-webpack-plugin": "^11.0.0",
"nodemon": "^2.0.20",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"mongoose": "^6.9.0"
}
}
Understanding of the heirarchy is as so:
.env.development.local > .env.local > .env.development > .env
With a few additional I have omitted which I don't plan to use.
I have been told that the issue is I need to specify the NODE_ENV
somewhere in the start script but I have yet to find any documentation or guide showing me how to do that.