DEV Community

Discussion on: How-to Read & Write Google Sheets with React

Collapse
 
azzmimy profile image
azzmi-my • Edited

Y'all guys gonna come to an issue,

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

You must do this inside your next.config.js to make everything work

module.exports = {
  // other next config
  i18n: {
    locales: ["en", "ms"],
    defaultLocale: "en",
  },
  env: {
     SPREADSHEET_ID : ***,
     SHEET_ID : ***,
     CLIENT_EMAIL : ***,
     PRIVATE_KEY : ***,

  },
  webpack: (config, options) => {
    config.node= {
    // Some libraries import Node modules but don't use them in the browser.
    // Tell Webpack to provide empty mocks for them so importing them works.
    ...config.node,
    fs: 'empty',
    child_process : 'empty',
    net : 'empty',
    tls: 'empty',
  }

    return config
  },
};
Enter fullscreen mode Exit fullscreen mode

ignore the other settings and focus on the webpack part.

Collapse
 
snikidev profile image
Nikita Kakuev

Magic! Thanks man! :)

Collapse
 
danielbaker06072001 profile image
Duc Minh Nguyen

Where do we find next.config.js file, I can't seem to find that file