如何解决Node.js的npm npx问题:你使用的是npm 2.15.12,但我更新了?

pcww981p  于 2022-11-14  发布在  Node.js
关注(0)|答案(2)|浏览(163)

我在使用npm时遇到了问题。我使用

npx create-react-app my_app

现在,我用npx create-react-app my_app启动了另一个(在另一个文件夹中),但是现在,出现了一个错误,说:
您使用得是npm 2.15.12,因此项目将使用不受支持得旧版本工具启动.请更新到npm 6或更高版本,以获得更好得,完全受支持得体验.
如果我让安装完成,就会出现一系列错误:“〉core-js@2.6.12安装后C:\用户\常用\桌面\安德烈斯\编程\React\企业\初级企业最终\我的应用程序\节点模块\React脚本\节点模块\babel核心\节点模块\babel注册\节点模块\core-js
node -e“try{需要('./postinstall')}捕获{}”
安装后,请在C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\node_modules\react脚本\node_modules\babel运行时\node_modules\core-js node -e“try{需要('./postinstall')}catch(e){}”
安装后,请在C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\node_modules\react脚本\node_modules\babel预设React应用程序\node_modules\babel运行时\node_modules\core-js node -e“try{require('./postinstall')}catch(e){}”
(...)一堆类似于/node_modules(...)的不同依赖项中的函数,最后:

npm ERR! Windows_NT 10.0.19043
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Usuario\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-audit" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts@0.9.x"
npm ERR! node v16.13.1
npm ERR! npm  v2.15.12
npm ERR! code ELIFECYCLE

npm ERR! core-js@2.6.12 postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! Exit status -4058
npm ERR! 
npm ERR! Failed at the core-js@2.6.12 postinstall script 'node -e "try{require('./postinstall')}catch(e){}"'.
npm ERR! This is most likely a problem with the core-js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node -e "try{require('./postinstall')}catch(e){}"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs core-js
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls core-js
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\npm-debug.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts@0.9.x has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Done.

我只是不明白是什么改变了,为什么会这样?我试着:
1.已卸载并重新安装的节点
1.已删除npm_cache
1.使用on CMD***npx where npm***查看npm的安装位置,显示:
C:\程序文件\节点js\npm.CMD
1.在那里我试过:
C:\Program Files\nodejs〉npm -v 8.3.0(因此它是最新的)
我该怎么办,我做错了什么?
我会感激你的帮助。

ipakzgxi

ipakzgxi1#

我在尝试从C:\\Users\\Usuario\\node_modules\\npm\\bin\\npm-cli.js中删除node_modules时遇到了类似问题
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Usuario\\node_modules\\npm\\bin\\npm-cli.js"

kqlmhetl

kqlmhetl2#

如果有人还需要帮助,我解决了这个问题。我无法找到造成这么多麻烦的过时文件在哪里,所以我运行命令npm list npm@2.15.12(尝试在你的CMD上作为admin而不是admin,同样在powershell中,我尝试了所有地方)。该命令显示:

C:\Users\Usuario
     --latest@0.2.0
       --npm@2.15.12

所以至少现在我知道它在“Usuario”里面的某个地方,但是我不知道具体去哪里找。然后我发现我在那里有一个node_modules文件夹(当我在其他地方已经有了它的时候),就把它删除了。就是这样,这解决了我的问题。
希望有人也觉得它有用。

相关问题