node-pkginfo icon indicating copy to clipboard operation
node-pkginfo copied to clipboard

Issue with /lib/pkginfo.js for finding package.json

Open owenashurst opened this issue 6 years ago • 1 comments

I've experienced a rather serious issue in which when attempting to debug in visual studio code a solution that uses pkginfo, I would get an error for pkginfo that the package.json file cannot be found inside \lib/package.json.

I believe on line 104 of pkgingfo.js file in /lib is wrong and should actually be looking 2 directories back in the root folder.

e.g.

wrong line: contents = require(dir + '/package.json'); should be: contents = require(dir + '../../package.json');

owenashurst avatar Dec 10 '18 15:12 owenashurst

I'm having the same issue. Cannot debug a project using VSCode because one of my packages uses pkginfo as a subdependency. This may also be just an issue with VSCode or our debug config, because I've had this happen with another package, where the module importer looks in the lib/build folder for package.json.

I get the following error:

Exception has occurred: Error
Error: Cannot find module '[PROJECT PATH]/node_modules/pkginfo/lib/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Function.pkginfo.find ([PROJECT PATH]/node_modules/pkginfo/lib/pkginfo.js:104:16)
    at Function.pkginfo.read ([PROJECT PATH]/node_modules/pkginfo/lib/pkginfo.js:122:22)
    at module.exports ([PROJECT PATH]/node_modules/pkginfo/lib/pkginfo.js:68:21)
    at Object.<anonymous> ([PROJECT PATH]/node_modules/pkginfo/lib/pkginfo.js:129:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

stvngrsh avatar Feb 12 '19 17:02 stvngrsh