Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message when requiring AVA from a REPL #1863

Closed
novemberborn opened this issue Jul 13, 2018 · 2 comments · Fixed by #1871
Closed

Better error message when requiring AVA from a REPL #1863

novemberborn opened this issue Jul 13, 2018 · 2 comments · Fixed by #1871

Comments

@novemberborn
Copy link
Member

This output isn't useful at all:

node -p "require('ava')"
path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.relative (path.js:1173:5)
    at Object.<anonymous> (/private/var/folders/2_/qczp184x76b2nl034sq5hvxw0000gn/T/tmp.x2ORUONLHR/node_modules/ava/lib/worker/ensure-forked.js:8:18)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)

The problem is in this line:

const fp = path.relative('.', process.argv[1]);

When using the REPL, process.argv[1] is empty. We should detect this and have a better error message.

@sanchitbansal10
Copy link

I would like to fix this..Thanks

@novemberborn
Copy link
Member Author

Hi @sanchitbansal10, there's already a PR for this: #1871. Hopefully you'll find another issue you'd like to work on 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants