Open cyango opened 10 months ago
same here
Also my react app is completely ignoring env-cmd with a simple env-cmd -f .env.android react scripts build. @toddbluhm can you help?
same. works for pnpm env:cmd
not with npm
Are you using this in an ESM setup? It seems the package currently doesn't support ESM and in this case fails with this error and hides the original one:
Error [ERR_REQUIRE_ESM]: require() of ES Module [...]\.env.js from [...]\node_modules\.pnpm\env-cmd@10.1.0\node_modules\env-cmd\dist\parse-env-file.js not supported.
.env.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename .env.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in [...]\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at Object.getEnvFileVars ([...]\node_modules\.pnpm\env-cmd@10.1.0\node_modules\env-cmd\dist\parse-env-file.js:21:33)
Same here. Remarks:
env.js
to env.cjs
, then I get rid of the message but the file is ignored. (this is even worst)I renamed the file to .cjs
and it worked! Thanks @caph1993
I have created a env.js file that i want to use with dynamic vars (that's why i'm using js) I'm using the same logic in many other apps and it works fine with env-cmd But on a specific project that has the same files and same folder structure, basically everything is the same. It gives this error:
Error: Failed to find .env file at path: ./devOps/env/env.js
Everything i do i doens't work, i removed node_modules, package-lock, gitignore, dockerignore, every .ignore
running this command: env-cmd -f ./devOps/env/env.js react-scripts start
what am I doing wrong?