[英]unable to create a new project with create-react-app
I've just finished installing create-react-app successfully.我刚刚成功安装了 create-react-app。 But, when I create a new project like below command, error happens.
但是,当我像下面的命令一样创建一个新项目时,就会发生错误。 Could you please give me a recommandation?
你能给我一个推荐吗?
system env.: - aws lightsail 1vcpu, 0.5G ram / ubuntu 18.04 - nodejs version : 13.9.0 - npm version : 6.13.7 - create-react-app version : 3.4.0系统环境: - aws lightsail 1vcpu,0.5G ram / ubuntu 18.04 - nodejs 版本:13.9.0 - npm 版本:6.13.7 - create-react-app 版本:3.4.0
~$ npm create-react-app my-app ~$ npm create-react-app my-app
Installing packages.安装软件包。 This might take a couple of minutes.
这可能需要几分钟时间。 Installing react, react-dom, and react-scripts with cra-template...
使用 cra-template 安装 react、react-dom 和 react-scripts...
core-js@2.6.11 postinstall /home/ubuntu/my-app/node_modules/babel-runtime/node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"
core-js@2.6.11 postinstall /home/ubuntu/my-app/node_modules/babel-runtime/node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"
Aborting installation.正在中止安装。 npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
npm install --save --save-exact --loglevel 错误 react react-dom react-scripts cra-template has failed。
Deleting generated file... node_modules Deleting generated file... package.json正在删除生成的文件... node_modules 正在删除生成的文件... package.json
Done.完毕。
It was a raised issue on github a couple of years back.. it was solved after switching to yarn.这是几年前在 github 上提出的一个问题.. 切换到纱线后解决了。 These commands could not solve the issue.
这些命令无法解决问题。
npm cache clean --force
create-react-app my-apps
Switching to Yarn worked!切换到 Yarn 成功了!
npm install -g yarn
yarn global add create-react-app
create-react-app my-app
See if this helps!看看这是否有帮助!
This error is due to the fact that a dependant module named core-js
is trying to run a post-install script.此错误是由于名为
core-js
的依赖模块正在尝试运行安装后脚本。 This post-install script spawns a child process and runs a shell script there.这个安装后脚本产生一个子进程并在那里运行一个 shell 脚本。 For some reason Node sets/assumes a wrong bash path by default.
出于某种原因,节点默认设置/假设错误的 bash 路径。 I had to manually change the path by running the following command.
我必须通过运行以下命令手动更改路径。
npm config set script-shell $(which sh)
Note : For Windows you might have to setup your own bash.exe
by installing something like git-bash and then you could assign the path similarly.注意:对于 Windows,您可能必须通过安装 git-bash 之类的东西来设置您自己的
bash.exe
,然后您可以类似地分配路径。
试试这个: npm cache clean --force
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.