question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working in Windows 10: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

See original GitHub issue

Issue: I’'m not able to load any .env/.js file using env-cmd How to reproduce:

  1. install npm install -g env-cmd
  2. create new folder and create .env file and paste below content (taken from example repo)
TEST_NAME=Default File Path Test
NODE_ENV=env-file
ENVVAR=exists
ENV_PATH=./.env
  1. Run command env-cmd in 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:open
  • Created 3 years ago
  • Reactions:10
  • Comments:14

github_iconTop GitHub Comments

3reactions
tmclean15commented, Apr 29, 2021

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:

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at normalizeSpawnArguments (child_process.js:411:3)
    at Object.spawn (child_process.js:551:13)
    at Object.spawn (/root/development/labnetic/node_modules/env-cmd/node_modules/cross-spawn/index.js:12:24)
    at Object.<anonymous> (/root/development/labnetic/node_modules/env-cmd/dist/env-cmd.js:57:30)
    at Generator.next (<anonymous>)
    at fulfilled (/root/development/labnetic/node_modules/env-cmd/dist/env-cmd.js:4:58) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Has this been looked into?

3reactions
rediska1114commented, Aug 19, 2020

@bastiankoetsier

I have same error when I do not specify the executable file.

env-cmd -f .env.development throwing an error, but env-cmd -f .env.development node sample.js work ok

macOS Catalina, Node v14.5.0, env-cmd@10.1.0

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found