sh:反应脚本:找不到命令

sh: react-scripts: command not found

我正在上 Udemy 的课程,我们将在其中使用 create-react-app。但是当我来到运行npm startand/oryarn start的时候就报错了

这是课程:Complete React Developer in 2020 (w: Redux, Hooks, GraphQL)

npx create-react-app test-npm(如果我使用 npm,则使用 --use-npm)

我们建议您先输入:

光盘测试
npm 开始

祝您黑客愉快!
➜ 2020 年完成 React Developer (w: Redux, Hooks, GraphQL) cd test
➜ test-npm git:(master) npm 或 yarn start

test-npm@0.1.0 start /Users/user/Udemy/Complete React Developer in 2020 (w: Redux, Hooks, GraphQL)/test
react-scripts start

npm 结果:

sh: react-scripts: command not found  
npm ERR! code ELIFECYCLE  
npm ERR! syscall spawn  
npm ERR! file sh  
npm ERR! errno ENOENT  
npm ERR! test@0.1.0 start: `react-scripts start`  
npm ERR! spawn ENOENT     
npm ERR!  
npm ERR! Failed at the test-npm@0.1.0 start script.  
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:  
npm ERR!     /Users/user/.npm/_logs/2020-01-23T18_09_30_919Z-debug.log

纱线结果:

➜  test-yarn git:(master) yarn start  
yarn run v1.21.1  
$ react-scripts start  
/bin/sh: react-scripts: command not found  
error Command failed with exit code 127.  
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我正在使用 mac(最新的 iOS),并将 zsh 与 oh my zsh 一起使用。

我的 .zshrc 文件:

(#) If you come from bash you might have to change your $PATH.  
(#) export PATH=$HOME/bin:/usr/local/bin:$PATH

(#)Path to your oh-my-zsh installation.  
export ZSH="/Users/mhagen/.oh-my-zsh"

ZSH_THEME="robbyrussell"

plugins=(git nvm)

source $ZSH/oh-my-zsh.sh

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

我的 .bash_profile 文件:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

我已经安装了:

➜  ~ nvm --version
0.35.2
➜  ~ node -v
v13.7.0
➜  ~ npm -v
6.13.6
➜  ~ yarn -v
1.21.1

我已经尝试删除 node_modules 和 package-lock/yarn 锁定文件并使用 npm 和 yarn 安装它们(每次都删除项目和新文件)。

我试过全局安装 create-react-app。但是我发现 none 的技巧是有效的。

希望这里有人能看到我的问题所在:/

这是对我有用的解决方案: 项目路径中任何文件夹的名称中都不能包含 space。

例如 user/project 1/反应 // This cause the error。 user/project1/反应// This is okay.