我正在学习有关Udemy的课程,我们将在其中使用create-react-app
。但是,当我运行npm start
和/或yarn start
时,出现错误。
这是课程:Complete React Developer in 2020 (w: Redux, Hooks, GraphQL)
npx create-react-app test-npm(如果我使用npm,则使用--use-npm)
我们建议您先输入:
cd测试npm开始
[骇客!in于2020年完成React开发(w:Redux,Hooks,GraphQL)CD测试➜test-npm git:(master)npm或yarn start
[email protected] 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! [email protected] start: `react-scripts start` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the [email protected] 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中使用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
和程序包锁定/纱线锁定文件,并同时使用npm和yarn安装它们(每次都删除项目和新文件)。
我已经尝试在全球范围内安装create-react-app。但是我发现的所有技巧都没有用。
希望有人在这里可以看到我的问题是:/
我面临着同样的问题。您是否找到了解决方案?谢谢!