Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodejs 16.x error: The programmatic API was removed in npm v8.0.0 #3885

Open
mukeshkmr776 opened this issue Jun 13, 2022 · 7 comments
Open
Labels
aix Aix specific issues

Comments

@mukeshkmr776
Copy link

mukeshkmr776 commented Jun 13, 2022

Details

I changed my Nodejs. from 14.x to 16.x and getting error:

Error: The programmatic API was removed in npm v8.0.0, stacktrace: Error: The programmatic API was removed in npm v8.0.0
    at Object.<anonymous> (/nodejs16/node_modules/npm/index.js:4:9)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/app/service.js:25:15)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

Unable to understand what is the breaking change in Nodejs 16.x which is causing this issue.

Node.js version

Old Nodejs : 14.17.0
New Nodejs : 16.15.1

Example code

Project code. Can't disclose source.

Operating system

IBM AIX - 7.2

Scope

runtime

Module and version

Not applicable.

@mukeshkmr776 mukeshkmr776 changed the title Nodejs not running for version 16.x Nodejs 16.x error: The programmatic API was removed in npm v8.0.0 Jun 13, 2022
@richardlau
Copy link
Member

The breaking change is, as indicated by the error message, npm 8. Node.js 14.x has npm 6, while Node.js 16 has npm 8. See this note from the npm team, nodejs/node#40168 (comment).

Even in Node.js 14 the programmatic API for npm is not requirable from the bundled npm without messing around with NODE_PATH (deprecated) or symlinks so this wasn't considered a breaking change for Node.js.

cc @nodejs/npm

@mukeshkmr776
Copy link
Author

@richardlau Thanks for the information. How to overcome this issue? :(
It means, we can't upgrade from Nodejs 14 to Node 16 ? :(

@fritzy
Copy link

fritzy commented Jun 13, 2022

If you want lower level access to things that npm does, then you may want to switch to using @npmcli/arborist or pacote, depending on what you used to be using the internal API for.

@mukeshkmr776
Copy link
Author

Where's list of internal API in npm?
We don't use require('npm'), but might be the dependencies using them.
How to fix this issue? Any suggestions would be highly appreciated.

would npm install again work?

@F3n67u
Copy link
Member

F3n67u commented Jun 14, 2022

Where's list of internal API in npm? We don't use require('npm'), but might be the dependencies using them. How to fix this issue? Any suggestions would be highly appreciated.

would npm install again work?

Error stack shows there is a require statement at line 25, this require required a package/module which used programmatic npm api caused the error.

    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/app/service.js:25:15)

Could you search the dependency tree of this package/module to find out which package cause the problem? After find out what package cause the problem, you may either update this package if it has fixed this problem or upstream fix to this package.

@anchezj
Copy link

anchezj commented Feb 24, 2023

Se tiene alguna solucion a este problema ?

@preveen-stack preveen-stack added the aix Aix specific issues label Jun 22, 2023
@masnoonJunaid
Copy link

@mukeshkmr776 did you solve it?, please update us if you find any solution, I am getting same error in Nextjs 14.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aix Aix specific issues
Projects
None yet
Development

No branches or pull requests

7 participants