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

Posted

技术标签:

【中文标题】为啥我收到此错误 - 错误:EPERM:不允许操作,找不到 mkdir \'C:\\Users\\Aniket\' 命令:create-react-app【英文标题】:Why I am getting this error - Error: EPERM: operation not permitted, mkdir 'C:\Users\Aniket' command not found: create-react-app为什么我收到此错误 - 错误:EPERM:不允许操作,找不到 mkdir 'C:\Users\Aniket' 命令:create-react-app 【发布时间】:2020-10-22 21:12:46 【问题描述】:

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

$ npx create-react-app my-app

然后我得到这样的错误:

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

我看到一些在线资源,他们说我必须从我的 Windows 用户名中删除空间,没有其他方法可以做到这一点吗?

【问题讨论】:

最可靠的解决方法是确保您的终端以管理员身份运行。您可以在高级快捷方式属性中将其设置为终端的默认设置。 【参考方案1】:

确保您已安装 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 config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global

【讨论】:

【参考方案2】:

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

就我而言,它是 CYBERC~1。

这在我的情况下很好用。

【讨论】:

【参考方案3】:

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

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

然后再次运行命令。

【讨论】:

以上是关于为啥我收到此错误 - 错误:EPERM:不允许操作,找不到 mkdir 'C:\Users\Aniket' 命令:create-react-app的主要内容,如果未能解决你的问题,请参考以下文章

npm publish 导致'错误:EPERM:不允许操作,取消链接...',errno -4048

呃!错误:EPERM:不允许操作

npm 错误!错误:EPERM:不允许操作,重命名

EPERM,不允许操作错误,配置存储

tar EPERM:不允许操作,futime

VS 代码 - 错误:EPERM:不允许操作