sindresorhus / meow

🐈 CLI app helper
MIT License
3.54k stars 151 forks source link

readPkgUp returns 'undefined' with pkg #156

Closed 1hcsaba closed 4 years ago

1hcsaba commented 4 years ago

Hi!

I am currently building a simple cli and using this lib with pkg (https://www.npmjs.com/package/pkg) to make an .exe after.

The issue is that it cannot find the package.json in the .exe form (i suppose)

...
options = {
pkg: readPkgUp.sync({ <---
    cwd: parentDir,
    normalize: false
}).packageJson || {},
....
\node_modules\meow\index.js:108
                }).packageJson || {},
                  ^
TypeError: Cannot read property 'packageJson' of undefined

It may require further investigation why, but for now i've commented out the look up at my side.

1hcsaba commented 4 years ago
...
cwd: process.cwd(),
...

seems to fix the issue, but.. maybe parentDir is used for a reason?

sindresorhus commented 4 years ago

That is a problem for pkg to fix. Meow assumes package.json exists as it always does for CLIs running in normal Node.js. Open an issue on pkg instead.