最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】npm start出错:react-native-scripts: command not found

npm crifan 5974浏览 0评论

 折腾:

【已解决】ReactNative中实现底部Tab页面和顶部导航栏

期间,npm start突然出错:

➜  rn_rse npm start
> [email protected] start /Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/react_native/rn_rse/rn_rse
> react-native-scripts start
sh: react-native-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `react-native-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/crifan/.npm/_logs/2017-10-09T09_08_38_204Z-debug.log

而刚才还好好的。

难道是安装了:npm install –save react-navigation

就导致此处脚本出错了???

难道此处新增加了几个js文件,就不行了?

去搜:

react-native-scripts: command not found

Expo app saying react-native-scripts: command not found when trying to run script to generate custom styles · Issue #1624 · ant-design/ant-design-mobile

‘react-native-scripts’ command not found on windows 7 os · Issue #211 · react-community/create-react-native-app

Error creating new app with “create-react-native-app” · Issue #118 · react-community/create-react-native-app

Unable to run playground example · Issue #1708 · react-community/react-navigation

重新去试试:

npm install

➜  rn_rse npm install
npm WARN deprecated [email protected]: connect 2.x series is deprecated
npm WARN [email protected] requires a peer of react@* but none was installed.
npm WARN [email protected] requires a peer of react-native@* but none was installed.
npm WARN [email protected] requires a peer of react-native@* but none was installed.
npm WARN [email protected] requires a peer of react@* but none was installed.
npm WARN [email protected] requires a peer of react-native@* but none was installed.
npm WARN [email protected] requires a peer of react@* but none was installed.
npm WARN [email protected] requires a peer of react-native@* but none was installed.
npm WARN [email protected] requires a peer of react-native@* but none was installed.
npm WARN [email protected] requires a peer of react@^16.0.0-alpha.12 but none was installed.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0-0 || ^16.0.0-0 but none was installed.
added 579 packages, removed 31 packages and updated 37 packages in 50.741s

然后安装了500多个包,感觉很诡异啊。。。

create-react-native-app not working with Yarn and NPM both · Issue #246 · react-community/create-react-native-app

结果npm start虽然可以运行,但是最后还是出错:

➜  rn_rse npm start
> [email protected] start /Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/react_native/rn_rse/rn_rse
> react-native-scripts start
17:16:38: Starting packager…
***ERROR STARTING PACKAGER***
Error: You are using npm version 5.0.0. We recommend version 4.6.1. To install it, run ‘npm i -g [email protected]’.
***ERROR STARTING PACKAGER***
Warning: Problem validating fields in app.json. See https://docs.expo.io/versions/v21.0.0/guides/configuration.html.
• ‘slug’ should match pattern “^[a-zA-Z0-9\-]+$”.
Error: React native is not installed. Please run `npm install` in your project directory.
17:16:41: Error starting packager: Error: Couldn’t start project. Please fix the errors and restart the project.
    at /xdl/src/Project.js:1217:11
    at Generator.next (<anonymous>)
    at step (/Users/crifan/dev/dev_root/daryun/Projects/xxx/rn_rse/rn_rse/node_modules/xdl/build/Project.js:1505:191)
    at /Users/crifan/dev/dev_root/daryun/Projects/xxxe/node_modules/xdl/build/Project.js:1505:361
    at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-native-scripts start`
npm ERR! Exit status 1
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/crifan/.npm/_logs/2017-10-09T09_16_41_502Z-debug.log

一堆的error,算了,还是先去解决:

【已解决】Error: You are using npm version 5.0.0. We recommend version 4.6.1. To install it, run ‘npm i -g [email protected]

【总结】

最终是:

先去把npm按照提示,换到4.6.1:

sudo npm i -g [email protected]

后,

npm install

npm start

就消除了此问题了。

转载请注明:在路上 » 【已解决】npm start出错:react-native-scripts: command not found

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.185 seconds, using 22.08MB memory