env-cmd: Error when using -f *.js file

What am I missing?

This is the error:

Error: Failed to find .env file at path: ./ignore/env.js
    at getEnvFile (.../xxxxx/node_modules/env-cmd/dist/get-env-vars.js:40:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

package.json script:

"scripts": {
    "start": "env-cmd -f ./ignore/env.js node ./dist/index.js"
}

env.js content:

module.exports = {
        EXTERNAL_ADD: true,
        INTERNAL_ADD: true,
        EXECUTIONS: "invisible"
}

Also tried using Promise.resolve

module.exports = Promise.resolve ({
        EXTERNAL_ADD: true,
        INTERNAL_ADD: true,
        EXECUTIONS: "invisible"
})

Tried using full path and still the same error.

OS: Mac env-cmd: “^10.1.0” Node: v10.22.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Hey everyone, sorry for not being around lately. I have been super busy working on a new/young startup with little free time to spare as well as migrating ts-standard over to the actual standard org.

However, I have nearly completed the next major iteration of this project. It will bring a lot of simplification, it will do a lot more “auto-discovery” of env files, as well as easy expandability using different file formats (I already have support for sync/async js/json/json5/yaml/toml/mjs/.env and maybe ts as well…still investigating) and maybe even env expansion within each env file (TBD). I have been reviewing each feature request/issue in github and would like to tackle everything I can before the release.

I have already fixed the error message stuff that is being discussed here as well. I apologize for my absence, but my day job has to come first for my family’s sake.