首页 文章

尝试使用条形码扫描仪时npm错误

提问于
浏览
0

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

例如,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

1 回答

  • 1

    使用react-native v0.44不推荐使用此库,您应该使用react-native-camera .

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

    如果您仍想使用此lib,请按照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}
          />
        );
      }
    

相关问题