node.js - 尝试在 linux 上运行 npm run build 时,NPM 给出 ELILIFECYCLE 错误

标签 node.js linux reactjs npm

我正在尝试在 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-readeryarn 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/

相关文章:

linux - 如何获取运行目录中的文件夹列表并将它们分别分配给一个变量?

node.js - 如何关闭从实时捕获源主动流式传输的 Node.js FFMPEG 子进程?

node.js - AWS Lambda : module initialization error: Error when running Camaro/Serverless

javascript - 使用 Octokit js 将内容添加到 Github 中的现有文件

linux - 无需手动输入任何命令

java - 如何通过curl从Oracle下载jdk文件?

javascript - useCallback 与 useMemo 以及何时使用它们

javascript - 如何使用 FilePond 使所选文件类型仅接受 docx?

reactjs - react : Why component's constructor is called only once?

node.js - Angular - 将 Json 对象传递给显示 [Object Object] 的子对象