最新消息:20210917 已从crifan.com换到crifan.org

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

npm crifan 4883浏览 0评论

 折腾:

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

期间,npm start突然出错:

➜  rn_rse npm start
> rn_rse@0.1.0 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! rn_rse@0.1.0 start: `react-native-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the rn_rse@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/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 connect@2.30.2: connect 2.x series is deprecated
npm WARN react-native-drawer-layout@1.3.2 requires a peer of react@* but none was installed.
npm WARN react-native-drawer-layout@1.3.2 requires a peer of react-native@* but none was installed.
npm WARN react-native-drawer-layout-polyfill@1.3.2 requires a peer of react-native@* but none was installed.
npm WARN react-native-tab-view@0.0.69 requires a peer of react@* but none was installed.
npm WARN react-native-tab-view@0.0.69 requires a peer of react-native@* but none was installed.
npm WARN react-navigation@1.0.0-beta.13 requires a peer of react@* but none was installed.
npm WARN react-navigation@1.0.0-beta.13 requires a peer of react-native@* but none was installed.
npm WARN jest-expo@21.0.2 requires a peer of react-native@* but none was installed.
npm WARN react-test-renderer@16.0.0-alpha.12 requires a peer of react@^16.0.0-alpha.12 but none was installed.
npm WARN react-redux@5.0.6 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
> rn_rse@0.1.0 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 npm@4.6.1’.
***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! rn_rse@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rn_rse@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/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 npm@4.6.1’

【总结】

最终是:

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

sudo npm i -g npm@4.6.1

后,

npm install

npm start

就消除了此问题了。

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

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
95 queries in 0.184 seconds, using 23.32MB memory