我正在尝试在 Linux 上使用 sudo npm run build
构建项目,但它给了我这个错误:
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
包.json
{
"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"
}
}
索引.js
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"));
最佳答案
Module not found: Error: Can't resolve 'react-qr-reader'
...
import QrReader from 'react-qr-reader';
运行 npm install --save react-qr-reader
或 yarn add react-qr-reader
你有react-qr-code
,但没有react-qr-reader
关于node.js - 尝试在 linux 上运行 npm run build 时,NPM 给出 ELILIFECYCLE 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48954877/