简体   繁体   English

找不到模块:无法解析“ child_process”

[英]Module not found: Can't resolve 'child_process'

while using reactjs I am getting this.webpack error incounter while npm start. 在使用reactjs时,我在npm启动时遇到了this.webpack错误。

    `./~/csvtojson/libs/core/workerMgr.js
    Module not found: Can't resolve 'child_process' in '/var/www/html/ReactLogin/node_modules/csvtojson/libs/core'`
    File : CsvRead.jsx

    import React from 'react';
    import ReactDOM from 'react-dom';

    var objects;

    var CsvRead = React.createClass({
        readFile:function(){
            var file = this.refs.file.files[0];
            var reader = new FileReader();
            reader.onload = function(evt){
                 var resultText = evt.target.result;
                 objects = this.csvToJson(resultText);
                 console.log(objects);
            }.bind(this);
            var newFile = file.slice(0,5000);
            reader.readAsText(newFile); 
        },
        csvToJson:function(csvString){
            var Converter = require("csvtojson").Converter;
            var converter = new Converter({});
            converter.fromString(csvString, function(err,result){
               //When i console log the result it is working but when i return The result:
               // i am getting a undefined error
               //console.log(result);
               return result;
            });
        },
        render:function(){
        console.log('i am here');
          return (
             <input type="file" ref="file" onChange={this.readFile} /> 
          );
        }
    });

File : GoogleChart.jsx : This file contains the import statement for including CsvRead.jsx but not working while including this file. File:GoogleChart.jsx:该文件包含用于包含CsvRead.jsx的导入语句,但在包含此文件时不起作用。

    import React, { Component } from 'react'
    import ReactDOM from 'react-dom';
    import { connect } from 'react-redux'
    import { createHashHistory } from 'history';
    import { Chart } from 'react-google-charts';
    import { CsvRead } from '../dynamic/CsvRead.jsx'

    const customHistory = createHashHistory();

    class GoogleChart extends Component {
        constructor(props) {
      super(props);
        this.state = {
          options: {
            title: 'Users Hours comparison',
            hAxis: { title: 'User'},
            vAxis: { title: 'Hours'},
            legend: 'none',
            axisTitlesPosition: 'out',
            'isStacked': true,
            colors: ['#0598d8', '#f97263'],
          },

          data :[
            ['User', 'workingHours', 'ExceptedWorkingHours'],
            ['user1', 500, 400],
            ['user2', 300, 200],
            ['user3', 1500, 650],
            ['user4', 1200, 470],
            ['user5', 1000, 700],
            ['user6', 500, 400],
            ['user7', 1300, 500],
            ['user8', 176, 55],
            ['user9', 310, 240],
            ['user10', 500, 400]
        ]
        };
      }

      render() {
        return (
          <CsvRead />
          <Chart
            chartType="ColumnChart"
            data = {this.state.data}
            options={this.state.options}
            graph_id="ColumnChart"
            width="100%"
            height="400px"
            legend_toggle
          />
        );
      }
    }


    function select(state) {
        return {
            users: state.users
        }
    }

    export default connect(select)(GoogleChart);

Anyone can help me on this.might not getting correct issue to resolve this problem. 任何人都可以在此方面为我提供帮助。可能无法获得正确的问题来解决此问题。 How to solve this issue? 如何解决这个问题?

csvtojson package is trying to spawn a child_process, which cannot be done in a browser. csvtojson软件包正在尝试生成child_process,这无法在浏览器中完成。 According to the doc, if you pass a { fork: false } in the options, it won't use child_process. 根据文档,如果您在选项中传递了{ fork: false } ,它将不会使用child_process。 Please paste your code. 请粘贴您的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法解析模块“child_process” - Can't resolve module 'child_process' 找不到模块:错误无法解析“child_process”,如何解决? - Module not found: Error can't resolve 'child_process', how to fix? 无法解析模块xmlhttprequest中的“ child_process” - Can't Resolve “child_process” in module xmlhttprequest 无法解析“child_process” - Can't resolve 'child_process' Next.js - 使用 BigQuery 客户端库时出现错误:找不到模块:无法解析“child_process” - Next.js - using BigQuery client library gives an error : Module not found: Can't resolve 'child_process' 错误:无法解析'child_process'Angular-cli - Error: Can't resolve 'child_process' Angular-cli 我正在尝试将 NPM package 作为插件注入到 Next.js 应用程序上,以避免出现“找不到模块:无法解析‘child_process’”错误 - I'm Trying to Inject An NPM package As A Plugin on A Next.js App to Avoid A "Module not found: Can't resolve 'child_process'" Error 错误:无法解析“child_process”和错误:无法解析“fs” - Error: Can't resolve 'child_process' and Error: Can't resolve 'fs' 使用Nodemailer和Webpack时无法解析dns和child_process - Can't resolve dns and child_process when using Nodemailer and Webpack 在audiosprite中加载错误-找不到模块:“ child_process” - Error loading in audiosprite - Module not found: 'child_process'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM