FS#72937 - [npm-check-updates] ncu cannot find it's own package.json

Attached to Project: Community Packages
Opened by Yichao Yu (yuyichao) - Monday, 06 December 2021, 13:06 GMT
Last edited by Toolybird (Toolybird) - Friday, 21 April 2023, 08:00 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Felix Yan (felixonmars)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

When running `ncu`, it throws an error
```
node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module '../../package.json'
Require stack:
- /usr/lib/node_modules/npm-check-updates/build/src/bin/cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/lib/node_modules/npm-check-updates/build/src/bin/cli.js:11:40)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/lib/node_modules/npm-check-updates/build/src/bin/cli.js' ]
}

Node.js v17.1.0
```

It appears that it's trying to find it's own package.json file using a relative path. In the repo and source tarball, `cli.{ts,js}` is `src/bin/` but in the package this is `build/src/bin` causing the relative path to be different. Copying the packages.json into the `build` directory fixes the problem but I don't know what's the correct fix....

Additional info:
* package version(s) 12.0.2
* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
Just run `ncu` command.
This task depends upon

Closed by  Toolybird (Toolybird)
Friday, 21 April 2023, 08:00 GMT
Reason for closing:  Fixed
Additional comments about closing:  Cannot repro with latest pkg. Assuming fixed.

Loading...