create-react-app 只创建 node_modules、package 和 package-lock [英] create-react-app only creates node_modules, package and package-lock

查看:35
本文介绍了create-react-app 只创建 node_modules、package 和 package-lock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的终端中:

D:\>npx create-react-app myapp                                                                                      
npx: installed 98 in 21.893s                                                                                        

Creating a new React app in D:\myapp.                                                                               

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


> core-js@2.6.11 postinstall D:\myapp\node_modules\babel-runtime\node_modules\core-js                               
> node -e "try{require('./postinstall')}catch(e){}"                                                                 


> core-js@3.6.5 postinstall D:\myapp\node_modules\core-js                                                           
> node -e "try{require('./postinstall')}catch(e){}"                                                                 


> core-js-pure@3.6.5 postinstall D:\myapp\node_modules\core-js-pure                                                 
> node -e "try{require('./postinstall')}catch(e){}"                                                                 

+ react-scripts@3.4.1                                                                                               
+ react-dom@16.13.1                                                                                                 
+ cra-template@1.0.3                                                                                                
+ react@16.13.1                                                                                                     
added 1613 packages from 750 contributors and audited 921730 packages in 287.89s                                    

58 packages are looking for funding                                                                                 
  run `npm fund` for details                                                                                        

found 1 low severity vulnerability                                                                                  
  run `npm audit fix` to fix them, or `npm audit` for details                                                       

安装后我的package.json:

My package.json after installing:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "cra-template": "1.0.3",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-scripts": "3.4.1"
  }
}

然后它永远停留在那里.我尝试安装全局 create-react-app,更新最新的 npm,删除 Appdata 中的 npm 还是不行,需要帮助

Then it stucks there forever. I tried to install global create-react-app, update the newest npm, delete npm in Appdata and still not work, need help

推荐答案

从 create-react-app 3.3.0 开始,不再推荐使用全局安装的 CRA.

这是 github 上提出的问题,但后来在此解决方案后关闭了

Since create-react-app 3.3.0 it's no longer recommended to use a global installation of CRA.

It was a raised issue on github but later got closed after this solution

npm rm -g create-react-app
npm install create-react-app
npx create-react-app my-app

它所做的就是:

命令 1:删除全局安装的 create-react-app

Command 1: deletes the create-react-app installed globally

命令 2:在本地安装 create-react-app

Command 2: Installs create-react-app locally

命令 3:使用所有预期的文件结构创建一个新的 react-app.

Command 3: Creates a new react-app with all the expected file structure.

试试这个,如果还是不行,请检查以下说明...

Try this, if even that doesn't work, Check the following instructions...

对于很多 Windows 用户来说,这是一个问题.

It was a problem for a lot of windows users.

即使在尝试了所有故障排除步骤后也没有解决问题.

Even after trying all the troubleshooting steps did not resolve the issue.

最后发现他们的环境变量中缺少一些路径.

Finally it was found that they had some missing paths in their environment variables.

注意:我们不是在这里讨论设置 npm 路径

直到将这些添加到 env 变量中才得到解决.

It did not get resolved until these were added to the env variables.

C:\Windows;C:\Windows\system32;C:\Windows\System32\Wbem

区分大小写,完全按照上面提到的方式粘贴

但是,随着时间的推移,这些错误变得越来越少,不确定这是否会有所帮助.

However, with time these errors have become fewer and fewer, not sure if this would help.

这篇关于create-react-app 只创建 node_modules、package 和 package-lock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆