一、创建一个新的react环境(npm ERR! Could not install from "Files odejs ode_cache\_npx13472" as it does not contain a package.json file.)

1. 安装新版本的 node.js

2. 执行 npx create-react-app my-app 创建一个 react 项目。

3. cd my-app

4. npm start

问题:在创建 npm create-react-app my-app 时,报错:

npm ERR! Could not install from "Files odejs ode_cache\_npx13472" as it does
not contain a package.json file.

原因:因为 node_cache 路径中有空格。

执行:  npm config get cache

结果为: D:Program Files odejs ode_cache

 路径中有空格。

解决: npm config set cache "D:Program~1 odejs ode_modules pm ode_cache"--global

 即可。

原文地址:https://www.cnblogs.com/lpp-11-15/p/14171696.html