You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue where exported npm module is a class which needs instantiating before it can be used with npm@8.3.0.
Below is a quick-and-dirty patch here where passing in the instanciate=true prop to your loader function correctly creates a singleton instance which is valid.
module.exports=(functionrequireNPM(npmPath,instanciate){GLOBAL_NPM_PATH=npmPathtry{varnpm=require(npmPath)if(instanciate)npm=newnpm();if(npm&&Object.keys(npm).length){returnnpm}}catch(e){if(e.message.indexOf('The programmatic API was removed')>=0){// for npm >= 8. Maybe programmatic api via require('npm') is no longer available// https://github.com/npm/cli/pull/3762returnrequireNPM(path.join(npmPath,'lib/npm.js'),true)}elseif(e.code!=='MODULE_NOT_FOUND'){throwe}}throwNotFoundError()})(GLOBAL_NPM_PATH)
I'm not certain if this is needed in all cases though since your original patch in #7 seems to imply this was already working in npm@8? If so maybe extend the catch to have a "try to instantiate this" clause if its an event emitter class return.
The text was updated successfully, but these errors were encountered:
Yeah unfortunately the downstream libraries that rely on it (this one for example) all break when they change how to setup the API object.
I kinda get how they need a class instantiating to use the NPM implementation but that raises the question on how it was working with NPM@8 in your last patch?
There is an issue where exported
npm
module is a class which needs instantiating before it can be used with npm@8.3.0.Below is a quick-and-dirty patch here where passing in the
instanciate=true
prop to your loader function correctly creates a singleton instance which is valid.I'm not certain if this is needed in all cases though since your original patch in #7 seems to imply this was already working in npm@8? If so maybe extend the catch to have a "try to instantiate this" clause if its an event emitter class return.
The text was updated successfully, but these errors were encountered: