create-react-app 无法在 Windows 10 中创建新的 React 应用程序

2024-01-06

I have Create-react-app version 1.4.3安装。当我尝试创建新的 App 时,我在命令提示符中收到以下消息。请帮助我找到并解决问题。

C:\Users\GSI-KOL\Desktop\server>create-react-app client

Creating a new React app in C:\Users\GSI-KOL\Desktop\server\client.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

[email protected] /cdn-cgi/l/email-protection postinstall C:\Users\GSI-KOL\Desktop\server\client\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

npm ERR! path C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
    
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\GSI-KOL\AppData\Roaming\npm-cache\_logs\2017-11-08T13_08_03_705Z-debug.log
    
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
    
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting client / from C:\Users\GSI-KOL\Desktop\server
Done.
    
C:\Users\GSI-KOL\Desktop\server>

我也面临着同样的问题。这是由于 npm 的问题。

请在命令行中运行以下命令

npm cache clean --force

然后运行

create-react-app <project Name>

如果问题仍然存在,请从 npm 切换到yarn

运行以下命令,它解决了我的问题

npm install -g yarn

yarn global add create-react-app

create-react-app <projectname>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

create-react-app 无法在 Windows 10 中创建新的 React 应用程序 的相关文章

随机推荐