【问题标题】:create-react-app Failing to create a new React app in windows 10create-react-app 无法在 Windows 10 中创建新的 React 应用程序
【发布时间】:2018-04-21 04:48:10
【问题描述】:

我安装了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...

uglifyjs-webpack-plugin@0.4.6 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>

【问题讨论】:

标签: reactjs


【解决方案1】:

我也遇到了同样的问题。这是由于 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>

【讨论】:

    【解决方案2】:

    您似乎需要管理员权限才能编写一些生成的文件。你可以创建一个具有管理员权限的终端实例然后重新发出命令吗?

    【讨论】:

      【解决方案3】:

      您之前可能运行过“create-react-app”,无论如何这就是我的问题。我解决这个问题的方法是使用 npm cache clean --force 并再次运行 create-react-app my-app

      【讨论】:

      • @Ssenyonjo 它会清理 npm 的缓存
      【解决方案4】:

      我怀疑 NPM 有问题。但是,这就是我能够解决它的方法

      按照以下步骤操作:

      1. npm install -g yarn

      2. yarn global add create-react-app

      3. Create-react-app &lt;projectname&gt;

      【讨论】:

        【解决方案5】:
        npm cache clean --force  
        

        那就试试

        npm create-react-app navigate
        

        【讨论】:

          【解决方案6】:

          我尝试了npm cache clean --force 和纱线路线,但都没有奏效。对我有用的是以管理员身份运行 Powershell,然后输入:

          set-executionpolicy remotesigned
          

          【讨论】:

            【解决方案7】:

            我也遇到了同样的问题,我用评论纠正了它
            下面给出:

            npm cache clean --force
            

            在此评论之后尝试: npx create-react-app 项目名称

            【讨论】:

            • 请不要发布重复的答案。
            【解决方案8】:

            试试这个

            npm install -g yarn
            
            yarn global add create-react-app
            
            create-react-app my-app
            

            【讨论】:

              【解决方案9】:

              我遇到了同样的问题,我通过以下步骤解决了这个问题:

              1. 确保您已安装了最新版本的 Node.js。 (https://nodejs.org/)
              2. npm install -g create-react-app
              3. create-react-app client-app --use-npmnpx create-react-app client-app --use-npm

              我希望它有所帮助..

              【讨论】:

              • 谢谢,重新安装 create-react-app 是我缺少的链接
              【解决方案10】:

              只需运行这个命令即可解决问题:

              sudo chown -R 1001:1001 "/home/&lt;user_name&gt;/.npm"

              【讨论】:

                【解决方案11】:

                这应该可以 npm cache clean --force

                【讨论】:

                  【解决方案12】:

                  这是由于网络问题尝试一一下载所有依赖或尝试清理缓存"npm cache clean --force" 之后尝试创建应用 npx create-react-app 。但是您的互联网连接应该是稳定的。

                  【讨论】:

                    【解决方案13】:

                    这就是我所做的

                    npm install -g yarn
                    

                    然后这个

                    npx create-react-app my-project
                    

                    【讨论】:

                      【解决方案14】:

                      对我来说,当我尝试运行“create-react-app”时,我没有连接到互联网,所以我连接并尝试了它,它有效,我猜它需要从互联网安装一些包.

                      【讨论】:

                        【解决方案15】:
                        Creating a new React app in C:\Users\CM\Downloads\react\github-profile.
                        Installing packages. This might take a couple of minutes.
                        Installing react, react-dom, and react-scripts...
                        
                        npm ERR! path C:\Users\CM\AppData\Roaming\npm-cache_cacache\content- 
                        
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b1
                        0893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806
                        
                        npm ERR! code EPERM
                        npm ERR! errno -4048
                        npm ERR! syscall lstat
                        npm ERR! Error: EPERM: operation not permitted, lstat 
                        'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content- 
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
                        b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6
                        5545008a3cad93d00f806'
                        npm ERR! { [Error: EPERM: operation not permitted, lstat 
                        'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content- 
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1f 
                        a335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6554500
                        8a3cad93d00f806']
                        
                        npm ERR! cause:
                        npm ERR! { Error: EPERM: operation not permitted, lstat 
                        'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content- 
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1
                        fa335b10893d67f7339e4 
                        af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806'
                        npm ERR! errno: -4048,
                        npm ERR! code: 'EPERM',
                        npm ERR! syscall: 'lstat',
                        npm ERR! path:
                        npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content- 
                        
                        
                        npm ERR! stack:
                        npm ERR! 'Error: EPERM: operation not permitted, lstat 
                        'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content- 
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
                        b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015
                        eec65545008a3cad93d00f806'',
                        npm ERR! errno: -4048,
                        npm ERR! code: 'EPERM',
                        npm ERR! syscall: 'lstat',
                        npm ERR! path:
                        npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content- 
                        v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335
                        b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93
                        d00f806',
                        npm ERR! parent: 'postcss-image-set-function' }
                        npm ERR!
                        npm ERR! The operation was rejected by your operating system.
                        npm ERR! It's possible that the file was already in use (by a
                        text editor or antivirus),
                        npm ERR! or that you lack permissions to access it.
                        npm ERR!
                        npm ERR! If you believe this might be a permissions issue, please double- 
                        check thenpm ERR! permissions of the file and its containing directories, or 
                        try  running
                        
                        npm ERR! the command again as root/Administrator (though this is not 
                        recommended).
                        npm ERR! A complete log of this run can be found in:
                        npm ERR! C:\Users\CM\AppData\Roaming\npm-cache_logs\2019-03-22T10_
                        27_19_722Z-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 github-profile/ from C:\Users\CM\Downloads\reactDone.``
                        

                        我遇到了类似的错误,但我尝试多次运行 create-react-app 命令并最终创建它,这是我的互联网连接的问题。检查您的网络连接

                        【讨论】:

                          【解决方案16】:

                          我也遇到了同样的问题,我是这样解决的:
                          1. 我首先使用 --force 关键字清理了我的缓存
                          2. 我在全球范围内重新安装了 create-react-app
                          3. 我重新创建了我的应用程序。

                          插图:

                          1. 清理缓存
                              npm cache clean --force
                          
                          1. 全局重新安装 create-react-app
                              npm i -g create-react-app
                          
                          1. 重新创建您的应用
                              create-react-app .
                          

                          【讨论】:

                            【解决方案17】:

                            我也遇到了同样的问题,根据错误,你的npm有问题。

                            试试这个命令

                            sudo chown -R 1000:1000 "<location of npm>/.npm"
                            

                            以我的命令为例

                            sudo chown -R 1000:1000 "/home/vidit/.npm"
                            

                            【讨论】:

                              【解决方案18】:

                              您只需要npm cache clean --force

                              100% 有效

                              就我而言,它发生在我中止了我发起的错误命令时。

                              然后我运行npm cache clean --force 并清理了缓存;之后,我运行了我的npx create-react-app,它运行良好。

                              快速提示:像这样从您的机器上卸载 create-react-app,npm un -g create-react-app 并运行 npx create-react-app 而不是 npm create-react-app,只要您想创建一个新的 react 应用程序。

                              原因:npx 将始终使用最新版本的 create-react-app 为您的项目创建新的 react 应用程序,并且 npx 会在完成后从您的机器上卸载/删除 create-react-app 包。

                              不用担心,安装 create-react-app 包大约需要 20 秒,所以...

                              npx create-react-app 发疯(即拒绝工作)时,不要忘记npm cache clean --force

                              【讨论】:

                                【解决方案19】:

                                我遇到了同样的问题,我这样做是为了解决问题;

                                1. npm clean cache --force..

                                这不起作用...我使用 --forcing 推荐的保护禁用返回了一个警告 npm WARN。

                                1. 我忽略了这一点,并通过运行全局重新安装了 create-react-app; npm i -g create-react-app

                                2. 我通过运行创建了我的应用程序(项目名称); 创建反应应用程序我的应用程序名称

                                我相信这应该对你有用..

                                【讨论】:

                                  【解决方案20】:

                                  我面临同样的问题。 我试试这个但它对我不起作用 npm cache clean --force

                                  所以卸载Node 并安装最新版本。它对我有用 希望它对你有用:)

                                  【讨论】:

                                    【解决方案21】:

                                    我通过将超时时间更改为大于 30000 解决了同样的问题 npx create-react-app appname -timeout=90000

                                    【讨论】:

                                      【解决方案22】:

                                      发生此问题是因为在您编写任何命令后任何命令正在运行/崩溃。所以,这应该工作

                                      npm cache clean --force
                                      

                                      【讨论】:

                                      • 嗨,Afendi,欢迎来到 Stack Overflow。您的答案是此问题的 a high scoring answer 的精确副本。请不要仅仅为了说“这对我有用”而发布答案。
                                      【解决方案23】:

                                      这是我的错误:

                                      3695 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\****\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
                                      3696 verbose node v6.10.3
                                      3697 verbose npm  v6.4.1
                                      3698 error code Z_BUF_ERROR
                                      3699 error errno -5
                                      3700 error zlib: unexpected end of file
                                      

                                      这解决了问题:

                                      npm cache clean --force and ran create-react-app my-app
                                      

                                      【讨论】:

                                        【解决方案24】:

                                        我遇到了同样的问题,我解决了在我的用户目录中创建项目 C:\Users\myuser\project

                                        好像是权限问题

                                        【讨论】:

                                          猜你喜欢
                                          • 1970-01-01
                                          • 2020-09-16
                                          • 2019-11-29
                                          • 1970-01-01
                                          • 1970-01-01
                                          • 2022-10-20
                                          • 2019-10-15
                                          • 1970-01-01
                                          相关资源
                                          最近更新 更多