npm ERR! Could not install from "Files\nodejs\node_cache\_npx\13888" as it does

859 阅读1分钟

npm 报错信息:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "Files\nodejs\node_cache\_npx\13888" as it does not contain a package.json file.

原因分析:node 路径带有空格,执行 npm config get cache 得到 D:\Program Files\nodejs\node_modules\npm\node_cache 确定带有空格

解决方案:改写路径

  • 执行 npm config edit 修改 .npmrc 文件,将带空格的路径改写为:D:\Program~1\nodejs\node_modules\npm\node_cache (这是 windows 的一种路径表达方式)
  • 执行 npm config set cache "D:\Program~1\nodejs\node_modules\npm\node_cache"--global