为什么我会收到此错误 - 错误:EPERM:不允许操作,未找到 mkdir 'C:\Users\Aniket' 命令:create-react-app

ano*_*ket 9 npm reactjs npm-install

我已使用此命令安装 react 应用程序

$ npx create-react-app my-app
Run Code Online (Sandbox Code Playgroud)

然后我得到了这样的错误:

Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket'
command not found: create-react-app
Run Code Online (Sandbox Code Playgroud)

我看到一些在线资源,他们说我必须从我的 Windows 用户名中删除空格,有没有其他方法可以使这个工作?

小智 25

请确保您已节点> = 8.10和NPM> = 5.6已经安装

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

npm install -g create-react-app
Run Code Online (Sandbox Code Playgroud)

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

npx create-react-app <Name of your app>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助 :)

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

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


小智 9

转到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。

配置

这在我的情况下工作正常。


小智 8

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

mkdir C:\cache
npm config set cache "C:\\cache"
Run Code Online (Sandbox Code Playgroud)

然后再次运行该命令。