env-cmd icon indicating copy to clipboard operation
env-cmd copied to clipboard

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

Open softmarshmallow opened this issue 3 years ago • 7 comments

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

softmarshmallow avatar May 16 '21 14:05 softmarshmallow

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

tmclean15 avatar Jun 24 '21 19:06 tmclean15

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

did you?

v4irajvimu avatar Oct 29 '21 09:10 v4irajvimu

I'm having the same issue

lawrensylvan avatar Dec 16 '21 13:12 lawrensylvan

I'm having this issue as well

saulelabra avatar Jan 25 '22 20:01 saulelabra

Also having this issue.

allidoisace avatar Feb 16 '22 23:02 allidoisace

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.

allidoisace avatar Feb 17 '22 19:02 allidoisace

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

puerschel93 avatar Dec 22 '22 13:12 puerschel93