Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found child_process #374

Closed
rawnly opened this issue Jul 28, 2020 · 10 comments
Closed

Module not found child_process #374

rawnly opened this issue Jul 28, 2020 · 10 comments

Comments

@rawnly
Copy link

rawnly commented Jul 28, 2020

Hi! I'm getting this error at build time (react project)

./node_modules/google-auth-library/build/src/auth/googleauth.js
Module not found: Can't resolve 'child_process' in ...

@theoephraim
Copy link
Owner

theoephraim commented Aug 7, 2020

Looks to be related to this? googleapis/google-auth-library-nodejs#371
Hopefully upgrading the google auth library will fix it.

I'll try to get to it soon!

@theoephraim
Copy link
Owner

Please take a look and let me know if the new version fixes this issue

@theoephraim
Copy link
Owner

going to close this for now. please reopen if it turns out to not be fixed!

@saavan-google
Copy link

saavan-google commented Nov 13, 2020

Please reopen - this is still a problem with Next.js on the latest versions

@willi-dev
Copy link

@SaavanNanavati I solved this issue in next.js by using API routes Next js.

@saavan-google
Copy link

@willi-dev thanks, that worked!

@wahyupriadi
Copy link

wahyupriadi commented Jan 16, 2021

@SaavanNanavati I solved this issue in next.js by using API routes Next js.

hi @willi-dev, could you provide an solved example or your project that using google-spreadsheet?
I can't figure it out using API routes in Next js.

@willi-dev
Copy link

willi-dev commented Jan 16, 2021

@SaavanNanavati I solved this issue in next.js by using API routes Next js.

hi @willi-dev, could you provide an solved example or your project that using google-spreadsheet?
I can't figure it out using API routes in Next js.

@wahyupriadi Do you use Next.JS API Routes?
here the example:

/* pages/api/hello.js */

import { GoogleSpreadsheet } from 'google-spreadsheet'

/**
 * this function for example append new row
 */
const appendSpreadsheet = async (row) => {
  const spreadsheetId = "" /* your spreadsheet id */
  const clientEmail = "" /* your client email */
  const privateKey = "" /* your privateKey */
  const sheetId = "" /* your sheet id */
  const doc = new GoogleSpreadsheet(spreadsheetId)
  try {
    await doc.useServiceAccountAuth({
      client_email: clientEmail,
      private_key: privateKey,
    });
    // loads document properties and worksheets
    await doc.loadInfo();
    const sheet = doc.sheetsById[sheetId];
    await sheet.addRow(row);
  } catch (e) {
    console.error('Error: ', e);
  }
}

export default (req, res) => {
  /* add new Row data */ 
  const newRow = { 
    col1: "col 1", 
    col2: "col 2"
  }
  appendSpreadsheet(newRow)
  res.statusCode = 200
  res.json({ 
    code: 200,
    data: {
      message: 'Hello'
     }
  })
}

after create function in API routes,
you can do ajax request using Axios or Fetch to your API Route in your component
example

/* ExampleComponent.js */
import React, { useEffect } from 'react'

const ExampleComponent = () => {
  
  useEffect(() => {
    fetch('/api/hello')
        .then( response => {
          return response.json()
        })
        .then( data => {
          console.log(data.data)
        })
        .catch (error => {
          console.log(error)
        })
  })
  
  return (
    <div>
    ....
    </div>
  )
}

export default ExampleComponent

@theoephraim theoephraim changed the title Module not found chil_process Module not found child_process Feb 7, 2022
@Zubyk-Yaroslav
Copy link

Zubyk-Yaroslav commented Jun 17, 2022

Hello men! But when I have deployed on the prod, this API did not work (
404 error...
I don't know what to do.

@theoephraim
Copy link
Owner

@WebDevKhm probably a configuration error. Do some debugging and make sure youre connecting to the right sheet ID and that your auth is set up correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants