I am working on a KeystoneJS project, currently running in development mode on NodeJS 12.14.0. About a week or ten days ago I noticed that even though I changed some environment variables in .env
the changes were not reflected at run-time. I've had to actually introduce new variables for the changes to take effect.
I've done searches (using WebStorm and VSC) in my code for the old information, but it only appears in my debug logs. That is to say, if the old value of my env var ANIMAL
was 'rooster' and I've changed it to 'lizard', 'rooster' does not appear anywhere in my code. And yet ANIMAL
keeps having the value rooster
at runtime. So that I have to introduce a new variable, NEW_ANIMAL=lizard
to make any changes work.
This does not happen with all env variables -- for instance, I just added a new one, TEST=1
, ran the app, stopped, changed it to TEST=2
, and the change worked fine. I do not see a pattern in what variables are affected.
I'm launching the project through Keystone's launch script, and I'm using TypeScript. My launch script is
"dev": "tsc && cross-env NODE_ENV=development DISABLE_LOGGING=true keystone --entry=tsout/index.js dev --port=4545"
dotenv
is being loaded at the top of the entry point to the project, /index.ts
,
require('dotenv').config();
which is run each time the project is restarted (for the record, I'm using Babel to be able to use import
instead of require
throughout the project, but I can't imagine that matters).
I just spent half an hour with another dev here going over this and neither of us could figure it out (actually we were trying to track down a weird bug and it turned out it was because even though the .env
variable had been changed, the app was still reading the old value).
If anyone has ever encountered anything like this before -- or has any clues on how to figure it out -- I'd be very grateful.
I include my package.json
below. I'm running MacOS 10.14.x and NodeJS 12.14.0, for what it's worth.
{
"name": "@keystonejs/example-projects-blank",
"description": "A blank KeystoneJS starter project.",
"private": true,
"version": "5.0.0",
"author": "The KeystoneJS Development Team",
"repository": "https://github.com/keystonejs/keystone.git",
"homepage": "https://github.com/keystonejs/keystone",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"dev": "tsc && cross-env NODE_ENV=development DISABLE_LOGGING=true keystone --entry=tsout/index.js dev --port=4545",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start",
"keystone": "keystone upgrade-relationships --index=tsout/index.js"
},
"dependencies": {
"@apollo/react-hooks": "^3.1.5",
"@arch-ui/fields": "^3.0.1",
"@arch-ui/layout": "^0.2.13",
"@arch-ui/typography": "^0.0.17",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@keystonejs/adapter-mongoose": "^8.1.0",
"@keystonejs/app-admin-ui": "^6.0.0",
"@keystonejs/app-graphql": "^5.1.7",
"@keystonejs/app-next": "^5.1.2",
"@keystonejs/app-static": "^5.1.2",
"@keystonejs/auth-password": "^5.1.7",
"@keystonejs/field-content": "^6.0.0",
"@keystonejs/fields": "^10.0.0",
"@keystonejs/fields-markdown": "^5.1.10",
"@keystonejs/fields-wysiwyg-tinymce": "^5.2.7",
"@keystonejs/file-adapters": "^6.0.2",
"@keystonejs/keystone": "^9.0.0",
"@keystonejs/list-plugins": "^5.1.4",
"@keystonejs/oembed-adapters": "^5.1.4",
"@tinymce/tinymce-react": "^3.6.0",
"@zeit/next-sass": "^1.0.1",
"apollo-boost": "^0.4.8",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.9",
"apollo-fetch": "^0.7.0",
"apollo-link-http": "^1.5.17",
"apollo-upload-client": "^13.0.0",
"app-root-path": "^3.0.0",
"axios": "^0.19.2",
"connect-mongo": "^3.2.0",
"cron": "^1.8.2",
"cross-env": "^7.0.0",
"date-fns": "^1.30.1",
"disqus-react": "^1.0.7",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-fileupload": "^1.1.6",
"express-session": "^1.17.1",
"graphql": "^14.6.0",
"graphql-tag": "^2.10.3",
"isomorphic-unfetch": "^3.0.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"loglevel": "^1.6.7",
"moment": "^2.24.0",
"multer": "^1.4.2",
"next": "^9.3.6",
"next-with-apollo": "^5.0.1",
"node-cron": "^2.0.3",
"node-fetch": "^2.6.0",
"node-sass": "^4.14.1",
"normalize-scss": "^7.0.1",
"ramda": "^0.27.0",
"react": "^16.13.1",
"react-apollo": "^3.1.5",
"react-dom": "^16.13.1",
"reading-time": "^1.2.0",
"require-directory": "^2.1.1",
"sanitize-html": "^1.23.0",
"string-strip-html": "^4.4.3",
"ts-node": "^8.10.1",
"typescript": "^3.8.3",
"uuid": "^7.0.2",
"validator": "^13.0.0",
"winston": "^3.2.1"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@types/express-fileupload": "^1.1.3",
"@types/node": "^13.13.5",
"@types/react": "^16.9.35",
"@types/winston": "^2.4.4",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"cz-conventional-changelog": "3.2.0",
"eslint-plugin-react-hooks": "^4.0.0",
"pino": "^6.2.1",
"pino-pretty": "^4.0.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}