toddbluhm / env-cmd

Setting environment variables from a file
https://www.npmjs.com/package/env-cmd
MIT License
1.73k stars 65 forks source link

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received undefined #283

Open softmarshmallow opened 3 years ago

softmarshmallow commented 3 years ago

The script from package.json

    ...
    "use:local": "env-cmd -f \".env.local\"",
    ...

image

yarn use:local
yarn run v1.22.10
$ env-cmd -f "./.env.local"
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at normalizeSpawnArguments (child_process.js:411:3)
    at Object.spawn (child_process.js:551:13)
    at Object.spawn (/Users/accounts-services/node_modules/cross-spawn/index.js:12:24)
    at Object.EnvCmd (/Users/accounts-services/node_modules/env-cmd/dist/env-cmd.js:59:26)
    at async Object.CLI (/Users/accounts-services/node_modules/env-cmd/dist/env-cmd.js:19:16) {
  code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

the .env.local from same directory

DATABASE_URL="postgresql://user:password@localhost:5432/main?schema=public"

# AWS CREDENTIALS
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=......
AWS_REGION=us-west-1

PASSWORD_KEY=internal-dev-password-key
JWT_SECRET_KEY=internal-dev-jwt-secret-key

# SLACK BOT HOOK KEYS
SLACK_BOT_TOKEN=your-testing-bot-token
SLACK_AQUISITION_NOTIFICATIONS_CHANNEL_ID=C022DJ74CJD

#GITHUB CLIENT VALUES
GITHUB_CLIENT_SECRET=add-your-test-github-client-secret
GITHUB_CLIENT_ID=12345678;

# NODE_ENV
NODE_ENV=development
tmclean15 commented 3 years ago

I am having the same issue, any update on this?

v4irajvimu commented 2 years ago

I am having the same issue, any update on this?

did you?

lawrensylvan commented 2 years ago

I'm having the same issue

saulelabra commented 2 years ago

I'm having this issue as well

allidoisace commented 2 years ago

Also having this issue.

allidoisace commented 2 years ago

Okay guys, I have the answer.

env-cmd -f .env.staging react-scripts build

env-cmd -f <my env file path> <commands for env> We are assuming that env-cmd -f .env.staging works alone. However, you have to specify a command after it to which the environment applies.

puerschel93 commented 1 year ago

Okay guys, I have the answer.

env-cmd -f .env.staging react-scripts build

env-cmd -f <my env file path> <commands for env> We are assuming that env-cmd -f .env.staging works alone. However, you have to specify a command after it to which the environment applies.

Thanks, i almost lost my mind because I used it with && like env-cmd -f .env.staging && react-scripts start