繁体   English   中英

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

[英]sh: react-scripts: command not found

我正在上 Udemy 的课程,我们将在其中使用create-react-app 但是当我运行npm start和/或yarn start ,出现错误。

这是课程: 2020 年完整的 React 开发人员(包括 Redux、Hooks、GraphQL)

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

我们建议您首先键入:

光盘测试
启动

快乐黑客!
➜ 2020 年完整的 React Developer (w: Redux, Hooks, GraphQL) cd 测试
➜ 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 lock 文件,并使用 npm 和 yarn 安装它们(每次都删除项目和新文件)。

我尝试在全局安装 create-react-app。 但是我发现的所有提示都不起作用。

希望这里有人能看到我的问题是什么:/

这是对我有用的解决方案: https : //stackoverflow.com/a/59235436/10225590项目路径中的任何文件夹的名称中不能有空格。

例如 user/project 1/react // This cause the error user/project1/react // This is okay

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM