sindresorhus / meow

🐈 CLI app helper
MIT License
3.53k stars 150 forks source link

ExperimentalWarning when using Meow with modules #220

Closed GBrachetta closed 1 year ago

GBrachetta commented 1 year ago

I'm using Meow in a CLI which uses modules rather than common imports (import meow from 'meow'), and I get a warning when, for example, I use the built-in --version flag, saying that importing JSON modules is an experimental feature:

(node:83927) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Obviously this pollutes the output.

Is there a way to hide this warning?

sindresorhus commented 1 year ago

I'm unable to reproduce this. What Node.js and Meow version?

GBrachetta commented 1 year ago

I believe the issue came when I imported my package.json in a modules file with:

import pkgJSON from '../package.json' assert {type: 'json'};

I don't get the warning if I use:

import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pkgJSON = require('../package.json');

Pity, because the former is a lot clearer.

sindresorhus commented 1 year ago

Closing as this is not a problem with Meow.

sindresorhus commented 1 year ago

Meow returns the package data, so not sure why you are importing it yourself.