安装nodejs npm npx时遇到的问题:
环境:Ubuntu22.04
我从nodejs官网上下载的Linux包,解压tar包后,里面有npm npx node 4个可执行文件,运行了./npm -V,出现了如下错误:
ERROR: npm v9.5.1 is known not to run on Node.js v8.17.0. You'll need to upgrade
to a newer Node.js version in order to use this version of npm. This version of
npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You
can find the latest version at https://nodejs.org/.
ERROR:
/home/w/node-v18.16.1-linux-x64/lib/node_modules/npm/lib/utils/exit-handler.js:21
const hasLoadedNpm = npm?.config.loaded
^
SyntaxError: Unexpected token .
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at module.exports (/home/w/node-v18.16.1-linux-x64/lib/node_modules/npm/lib/cli.js:81:23)
这个问题卡了有3天左右了,恳请前驱们能够指导下