I’m trying to build the project with sudo npm run build
on linux but it give me this error:
JavaScript
x
ubuntu@ip:/var/www/reactcamera$ sudo npm run build
> youtubechannelvideos@0.1.0 build /var/www/reactcamera
> react-scripts build
Creating an optimized production build
Failed to compile.
Module not found: Error: Can't resolve 'react-qr-reader' in '/var/www/reactcamera/src'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! youtubechannelvideos@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the youtubechannelvideos@0.1.0 build 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! /home/ubuntu/.npm/_logs/2018-02-23T19_07_23_567Z-debug.log
package.json
JavaScript
{
"name": "youtubechannelvideos",
"version": "0.1.0",
"private": true,
"dependencies": {
"fetch": "^1.1.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1",
"react-youtube": "^7.5.0",
"dns": "file:./src/mock/dns",
"react-qr-code": "0.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
index.js
JavaScript
import React from 'react';
import ReactDOM from 'react-dom';
import YouTube from 'react-youtube';
import Fetch from 'fetch';
import QrReader from 'react-qr-reader';
class Test2 extends React.Component{
constructor(props){
super(props)
}
render(){
return (<RenderOnClick buttonName="Show Camera" element={<ShowPreview/>}/>);
}
}
ReactDOM.render(<Test2/>, document.getElementById("root"));
Advertisement
Answer
JavaScript
Module not found: Error: Can't resolve 'react-qr-reader'
…
JavaScript
import QrReader from 'react-qr-reader';
run npm install --save react-qr-reader
or yarn add react-qr-reader
you have react-qr-code
, but not react-qr-reader