Giter VIP home page Giter VIP logo

Comments (5)

cyantree avatar cyantree commented on June 8, 2024 1

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\[email protected]\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\[email protected]\node_modules\env-cmd\dist\parse-env-file.js:21:33)

from env-cmd.

gganster avatar gganster commented on June 8, 2024

same here

from env-cmd.

cyango avatar cyango commented on June 8, 2024

Also my react app is completely ignoring env-cmd with a simple env-cmd -f .env.android react scripts build.
@toddbluhm can you help?

from env-cmd.

LizDodion avatar LizDodion commented on June 8, 2024

same. works for pnpm env:cmd not with npm

from env-cmd.

caph1993 avatar caph1993 commented on June 8, 2024

Same here.
Remarks:

  1. If I rename my env file from env.js to env.cjs, then I get rid of the message but the file is ignored. (this is even worst)
  2. A solution in my case was ro remove "type": "module" from the package.json of the folder and its parent.

from env-cmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.