React: error An unexpected error occurred: “EPERM: operation not permitted, rename...

使用react-create-app安装的时候报出如上的错误。

解决办法是:再执行一次…

因为这个错误是React尝试重命名某个没有目录权限下文件时报出的错误,所以不妨打开那个目录看看:
React: error An unexpected error occurred: “EPERM: operation not permitted, rename..._第1张图片
错误中需要将create-react-app.cmd.cmd 重命名为 create-react-app.cmd

然而我打开目录发现已经重命名成功了。所以感觉再执行一次应该是可以,结果重新执行了一次就真的可以了…

另外顺带说一句,这个目录应该是全局安装才会报出的,也就是比如如下的安装方式:

yarn create react-app test-react-hook

但facebook是推荐使用npx安装

If you’ve previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

上边官方建议:如果以前全局安装了create-react-app,建议先卸载…

然后这样安装

npx create-react-app my-app
cd my-app
npm start

原因是使用npx每次都会重新下载create-react-app这个初始化工具,进而能够永远初始化官方最新的脚手架工程。

你可能感兴趣的:(错误,react)