question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found `child_process`

See original GitHub issue

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 ...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
willi-devcommented, 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
1reaction
theoephraimcommented, Aug 7, 2020

Looks to be related to this? https://github.com/googleapis/google-auth-library-nodejs/pull/371 Hopefully upgrading the google auth library will fix it.

I’ll try to get to it soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error can't resolve 'child_process', how to fix?
But as soon as I try to use child process, using 'require("child_process")' I get the following error when trying to build the extension....
Read more >
Module not found: Can't resolve 'child_process' #192 - GitHub
error whenever I try to use node-notifier. I'm using Node v6.11.2 and the code is copy-paste from the examples. Any ideas?
Read more >
cannot find module 'child_process' or its corresponding type ...
To fix the error "cannot find module 'childprocess' or its corresponding type declarations", you need to install the types for the childprocess module...
Read more >
Module not found: Error can't resolve in react - YouTube
The following issues are handled:1. Module not found : Error can't resolve ' child_process '2. Uncaught ReferenceError: the process is not ...
Read more >
Node.js Child Process - GeeksforGeeks
Node.js is a JavaScript runtime that offers a variety of modules to work with ... The shell option is not supported by child_process.fork()....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found