【问题标题】:npm errors while attempting to use barcode scanner尝试使用条形码扫描仪时出现 npm 错误
【发布时间】:2017-12-09 05:59:51
【问题描述】:

我正在尝试使用条形码阅读器,因为我的应用确实需要它,但我无法启动我找到的任何项目。

例如,https://github.com/ideacreation/react-native-barcodescanner。我应该使用哪个命令来启动它?

$ cd /c/Users/Me/Desktop/react-native-barcodescanner-master 
$ npm i
$ npm i --save react-native-barcodescanner
npm ERR! Windows_NT6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Me\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "--save" "react-native-barcodescanner"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10
npm ERR! code ENOSELF
npm ERR! Refusing to install react-native-barcodescanner as a dependency of itself
$ npm start npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Me\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.3 npm ERR! npm  v3.10.10
npm ERR! missing script: start

【问题讨论】:

  • 你是第一次使用 node / npm 代码吗?如果是这样,您应该了解节点项目。如果没有,请发布您的 package.json。
  • 您可以识别文件 npm-debug.log 中出了什么问题,它将位于 C:\Users\Me\Desktop\react-native-barcodescanner-master\npm-debug.log阅读它
  • 学习node.js的相关链接How do I get started with Node.js

标签: react-native barcode-scanner


【解决方案1】:

该库已被 react-native v0.44 弃用,您应该使用 react-native-camera

您使用的命令npm i --save react-native-barcodescanner 用于将此库安装到您的项目中。

如果你还想使用这个库,请关注this instruction

进口:

import BarcodeScanner from 'react-native-barcodescanner';

然后在你的组件中使用:

render() {
    return (
      <BarcodeScanner
        onBarCodeRead={this.barcodeReceived}
        style={{ flex: 1 }}
        torchMode={this.state.torchMode}
        cameraType={this.state.cameraType}
      />
    );
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 2012-08-08
    相关资源
    最近更新 更多