Not working in Windows 10: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
See original GitHub issueIssue: I’'m not able to load any .env/.js file using env-cmd
How to reproduce:
- install
npm install -g env-cmd - create new folder and create
.envfile and paste below content (taken from example repo)
TEST_NAME=Default File Path Test
NODE_ENV=env-file
ENVVAR=exists
ENV_PATH=./.env
- Run command
env-cmdin that folder This throws error which is mentioned below:
PS C:\Users\1gour\OneDrive\Documents\old\Github\new> env-cmd
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:112:11)
at Object.normalize (path.js:266:5)
at parseNonShell (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\node_modules\cross-spawn\lib\parse.js:49:31)
at parse (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\node_modules\cross-spawn\lib\parse.js:88:37)
at Object.spawn (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\node_modules\cross-spawn\index.js:9:20)
at Object.EnvCmd (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\dist\env-cmd.js:59:26)
at async Object.CLI (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\dist\env-cmd.js:19:16) {
code: 'ERR_INVALID_ARG_TYPE'
}
I tried to install it locally instead of globally but still same issue.
Also, If I rename .env to anything else like .env.dev it denies its existence:
PS C:\Users\1gour\OneDrive\Documents\old\Github\new> env-cmd -f .env.dev
Error: Failed to find .env file at default paths: [./.env,./.env.js,./.env.json]
at getEnvFile (C:\Users\1gour\AppData\Roaming\nvm\v12.15.0\node_modules\env-cmd\dist\get-env-vars.js:58:11)
I’ve also tried using async file i.e. async-env.js but still same issue Failed to find .env file
I’ve tried uninstalling installing again but doesn’t work. I’m not sure if somebody tested this package in Windows or not but I can’t make it work!
Platform: Windows 10 Teminal: Powershell core 6.2.3 (also tried with cmd but same error) “env-cmd”: “^10.1.0”,
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:14
Top Results From Across the Web
The "path" argument must be of type string ... - Stack Overflow
'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined' · 2. Try deleting and re-installing node ...
Read more >[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path ...
[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined · This story will cover three possible fixes: · 1:...
Read more >[err_invalid_arg_type]: the "path" argument must be of type ...
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined at Object.
Read more >The "path" argument must be of type string. Received ... - GitHub
Converts JSON schema to MD. Actual Behaviour. The following error is thrown: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of ...
Read more >The path argument must be of type string - Reactgo
In this tutorial, we are going to learn about how to fix the TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string…...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m having the same issue, I’ve tried running on both MacOS Catalina 10.15.7 and Ubuntu 20.04. I’ve tried multiple different versions, including all versions from 9.0.0-10.1.0, with the same result:
Has this been looked into?
@bastiankoetsier
I have same error when I do not specify the executable file.
env-cmd -f .env.developmentthrowing an error, butenv-cmd -f .env.development node sample.jswork okmacOS Catalina, Node v14.5.0, env-cmd@10.1.0