npm error Cannot find module ‘negotiator‘ 的处理
本想运行npm create vue@latest,但提示:
npm error code MODULE_NOT_FOUND
npm error Cannot find module 'negotiator'
npm error Require stack:
npm error - C:\Users\Administrator\AppData\Roaming\nvm\v18.16.1\node_modules\npm\node_modules\tuf-js\node_modules\make-fetch-happen\lib\cache\policy.js
……
npm error A complete log of this run can be found in: C:\Users\Administrator\AppData\Local\npm-cache\_logs\2025-05-27T15_20_48_021Z-debug-0.log
去目录:C:\Users\Administrator\AppData\Roaming\nvm\v18.16.1\node_modules\npm\node_modules\negotiator 中看,确实为空。
通过各种命令,如:npm install -g npm@latest,npm install -g negotiator等,都是提示:Cannot find module 'negotiator'
后面我看到 C:\Users\Administrator\AppData\Roaming\nvm\v18.16.1\node_modules\cnpm\node_modules\npm\node_modules\negotiator 目录中有内容,就把它拷贝到 前面的 npm 目录中,然后再运行各种命令,就正常了。
不知道什么原因造成,只是误打误撞解决了。