Closed dilraj-vidyard closed 1 year ago
:-(
I know :(((( Forgive me
I believe the error message is clear enough. You should read our documentation and examples before use.
nice
u must be fun at parties
lol. Do you mean we didn't explain in the documentation why we mark this parameter as required?
Hmmm, maybe you are right.
Feel free to reopen it if you would like to discuss further.
Coming here to thank you OP for posting this!
I had the same issue. š
It wasn't immediately clear to me in the example from the documentation that the importMeta
was required (I thought it was part of the set up like the rainbow
boolean option so it was only relevant for that particular š¦ example).
I also misunderstood the error message. I thought
"TypeError: The `importMeta` option is required. Its value must be `import.meta`."
meant I had to do something like:
{ importMeta: 'some-magic-meta-data-for-my-module-maybe-the-file-path-or-something' }
or maybe something more literal like:
{ importMeta: `import.meta` }
I believe I misread the documentation because the first example is a little long and the required options got buried by the rest of the example. Maybe something like this would be more obvious?
#!/usr/bin/env node
import meow from 'meow';
import foo from './lib/index.js';
const cli = meow(`text to display for the --help option`,
{
importMeta: import.meta, // required
flags: {
rainbow: {
type: 'boolean',
shortFlag: 'r'
}
}
});
/*
{
input: ['unicorns'],
flags: {rainbow: true},
...
}
*/
foo(cli.input.at(0), cli.flags);
and then later on give a longer example where your users can describe the usage in more details? š šš¼
@chuyaguo2014 you should open a new issue suggesting more documentation. I like adding the // Required
comment to the usage example.
I apologize if this is clear for most people, but I've dealt with a lot of headaches with node
--experimental-modules
.My Experience
When I imported
meow
, with:import meow from 'meow';
And did
const cli = meow();
,This is what I saw:
I was convinced that it was something to do with the ES module stuff and it took me down the wrong path for hours.
The Solution
It wasn't until I went to the docs and searched specifically for the
importMeta
; (š®āšØ definitely should have done that soon š¤¦)Proposal
BOOST the error message on GoogleThus, I decided to open an issue in case anyone else searches for the same issue.Maybe provider a clearer message?
I don't know enough about
meow
to offer a better message.