Why I am getting this error - Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket' command not found: create-react-app

Why I am getting this error - Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket' command not found: create-react-app

我已经使用这个命令安装了 React 应用程序

$ npx create-react-app my-app

然后我得到这样的错误:

Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket'
command not found: create-react-app

我看到一些在线资源,他们说我必须从我的 Windows 用户名中删除 space,是否有任何其他方法可以实现此目的?

确保您已经安装了 node>=8.10 和 npm>=5.6

首先尝试全局安装,使用命令

npm install -g create-react-app

然后,您可以使用以下命令创建您的应用程序,

npx create-react-app <Name of your app>

希望这对您有所帮助:)

编辑:上述解决方案可能有效,但不推荐使用它来解决此问题。请参考https://create-react-app.dev/docs/getting-started

我参考了底部给出的解决方案和其他一些帖子以使用以下命令: npm 配置设置缓存“C:\Users\mycomputer~1name\AppData\Roaming\npm-cache”--global

转到 c:/users 打开命令提示符并 运行 dir /x 检查您用 dir/x 找到的更短的名称,如图所示和 运行 npm config set cache "C:/Users/<shortname-you-found-with-dir/x>/AppData/Roaming/npm-cache" --global

在我的例子中是 CYBERC~1。

这对我来说很好用。

对我来说最简单的方法是:

mkdir C:\cache
npm config set cache "C:\cache"

然后再次运行命令。