我用create-react-app
创建了一个示例应用程序,我启动了项目并使用npm install prop-types
安装了该软件包。我收到了一堆警告:
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/jest as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/jest
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/regjsparser as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/regjsparser
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/jsesc as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/jsesc
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/fsevents/node_modules/.bin/node-pre-gyp as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/fsevents/node_modules/node-pre-gyp
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/esparse as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/esprima
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/esvalidate as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/esprima
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/.bin/cssesc as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/cssesc
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/acorn-globals/node_modules/.bin/acorn as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/acorn-globals/node_modules/acorn
npm WARN rm not removing /Users/carlosgrijalva/Programming/sample/node_modules/@babel/generator/node_modules/.bin/jsesc as it wasn't installed by /Users/carlosgrijalva/Programming/sample/node_modules/@babel/generator/node_modules/jsesc
当我运行npm start
时,出现以下错误:
> sample@0.1.0 start /Users/carlosgrijalva/Programming/sample
> react-scripts start
sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! sample@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the sample@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/carlosgrijalva/.npm/_logs/2018-11-02T15_33_21_597Z-debug.log
以下是我的npm,node和create-react应用的版本
node --version: v8.10.0
create-react-app --version: 2.0.4
npm --version: 5.6.0
我感觉到问题是同时安装了纱和NPM?不过不确定,有人遇到了这个问题吗?
答案 0 :(得分:2)
同时安装Yarn和NPM很好,不会导致任何问题。实际上,许多项目都同时具有yarn和npm,以便于更多用户使用。
“ sh:react-scripts:未找到命令”:关于此问题,也许您的node_modules不能正常工作。
因此,删除您的node_modules,然后再次npm npm install 。
关于警告,您应该添加具有 npm install prop-types -save的软件包,而不是npm install prop-types 。