Cannot find module '_process' from generated next_blog.js

I have spent a great deal of time trying to figure out why I’m getting the error below. It’s clear that the '_process' module that’s missing is being required by a generated function to get the next blog post of my netlify/next app (using this plugin of course). I could be mistaken but I believe it’s this plugin (or something higher up in the netlify build?) that’s generating these files (screenshot below). I’ve scoured docs and have tried to mess around with directory structures, configurations, etc. but cannot figure out why this module is being required by these generated files w/out it being accessible. Of course, I tried to install _process via yarn but no dice there either. Any suggestions here would be greatly appreciated. Thanks for all the awesome work you all do!

  Dependencies installation error                               
────────────────────────────────────────────────────────────────

  Error message
  A Netlify Function failed to require one of its dependencies.
  If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.

  In file "/home/thislogancall/code/next-netlify-project/.netlify/functions/next_blog/next_blog.js"
  Cannot find module '_process'
  Require stack:
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/zip-it-and-ship-it/src/main.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/plugins_core/functions/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/commands/get.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@netlify/build/src/core/main.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/lib/build.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/commands/build/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/plugin.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/config.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/config/lib/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/command/lib/command.js
  - /home/thislogancall/code/next-netlify-project/node_modules/@oclif/command/lib/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/src/index.js
  - /home/thislogancall/code/next-netlify-project/node_modules/netlify-cli/bin/run

  Resolved config
  build:
    command: yarn run create
    commandOrigin: config
    functions: /home/thislogancall/code/next-netlify-project/.netlify/functions
    publish: /home/thislogancall/code/next-netlify-project/dist
  plugins:
    - inputs: {}
      origin: config
      package: '@netlify/plugin-nextjs'
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Directory structure:

image

Dependency version:

    "netlify-lambda": "^2.0.3",
    "next": "^9.5.3",
    "next-transpile-modules": "^4.1.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "@netlify/plugin-nextjs": "^2.0.0",
    "netlify-cli": "^3.4.7",

Babel config:

{
  "presets": [
    "@babel/preset-env",
    "next/babel"
  ],
  "retainLines": true,
  "env": {
    "production": {
      "plugins": [
        [
          "@babel/plugin-transform-regenerator",
          {
            "asyncGenerators": true,
            "generators": true,
            "async": true
          }
        ],
        [
          "@emotion/babel-plugin",
          {
            "hoist": true
          }
        ]
      ]
    },
    "development": {
      "plugins": [
        [
          "@babel/plugin-transform-regenerator",
          {
            "asyncGenerators": true,
            "generators": true,
            "async": true
          }
        ],
        [
          "@emotion/babel-plugin",
          {
            "sourceMap": true
          }
        ]
      ]
    }
  }
}

You can try updating your dependencies to see if that fixes it, just like an issue here: Uncaught Error: Cannot find module '_process' · Issue #519 · primus/primus · GitHub. It’s just a related error, not specific to you, but point being, updating dependencies might help.

Or try adding process to your dependencies list.

Wow. That fixed it. No idea what dependency was the issue but it works! Thanks @hrishikesh!