Gatsby Site Build Failed - Error: Cannot find module 'node:stream'

This is my first post on here, pardon if I am missing something.

I have been working on this Gatsby site with netlify CMS and it has been building fine on Netlify.
My last build was done about a month ago and it was deployed successfully, however today after I made some minor changes(only changing some react code), the deploy started failing with a build error. I have been trying to troubleshoot the “Cannot find module ‘node:stream’” error but I have not found any solution yet.

Running “npm run build” locally works fine and I am not quite sure what this node:stream module is, I have tried ‘npm i node-stream’ but I am not sure if they are the same module.

Any help is appreciated! Thank you!

Below is the build log with the error:


3:59:06 PM: npm packages installed
3:59:07 PM: Successfully installed dependencies
3:59:07 PM: Starting build script
3:59:08 PM: Detected 1 framework(s)
3:59:08 PM: “gatsby” at version “4.25.8”
3:59:08 PM: Section completed: initializing
3:59:10 PM: ​
3:59:10 PM: Netlify Build
3:59:10 PM: ────────────────────────────────────────────────────────────────
3:59:10 PM: ​
3:59:10 PM: ❯ Version
3:59:10 PM: @netlify/build 29.54.1
3:59:10 PM: ​
3:59:10 PM: ❯ Flags
3:59:10 PM: accountId: ****
3:59:10 PM: baseRelDir: true
3:59:10 PM: buildId: 66df5310d3bab5789e1603fe
3:59:10 PM: deployId: 66df5310d3bab5789e160400
3:59:10 PM: ​
3:59:10 PM: ❯ Current directory
3:59:10 PM: /opt/build/repo
3:59:10 PM: ​
3:59:10 PM: ❯ Config file
3:59:10 PM: /opt/build/repo/netlify.toml
3:59:10 PM: ​
3:59:10 PM: ❯ Context
3:59:10 PM: production
3:59:10 PM: ​
3:59:10 PM: ❯ Installing plugins
3:59:10 PM: - @netlify/plugin-gatsby@3.8.1
3:59:20 PM: ​
3:59:20 PM: ❯ Loading plugins
3:59:20 PM: - @netlify/plugin-gatsby@3.8.1 from Netlify app
3:59:21 PM: No Gatsby cache found. Building fresh.
3:59:21 PM: ​
3:59:21 PM: build.command from netlify.toml
3:59:21 PM: ────────────────────────────────────────────────────────────────
3:59:21 PM: ​
3:59:21 PM: $ npm run build
3:59:22 PM: > gatsby-starter-decap-cms@1.1.3 build /opt/build/repo
3:59:22 PM: > npm run clean && gatsby build
3:59:22 PM: > gatsby-starter-decap-cms@1.1.3 clean /opt/build/repo
3:59:22 PM: > gatsby clean
3:59:22 PM: info Deleting .cache, public, /opt/build/repo/node_modules/.cache/babel-loader, /opt/build/repo/node_modules/.cache/terser-webpack-plugin
3:59:22 PM: info Successfully deleted directories
3:59:25 PM: success compile gatsby files - 1.192s
3:59:25 PM: success load gatsby config - 0.014s
3:59:25 PM: warning Plugin gatsby-plugin-netlify-identity is not compatible with your gatsby version 4.25.8 - It requires gatsby@^2.0.0
3:59:26 PM: Error: Cannot find module ‘node:stream’
3:59:26 PM: Require stack:
3:59:26 PM: - /opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js
3:59:26 PM: - /opt/build/repo/node_modules/cheerio/dist/commonjs/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby-remark-images/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plugin.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/cli.js
3:59:26 PM: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
3:59:26 PM: at Module.require (internal/modules/cjs/loader.js:952:19)
3:59:26 PM: at require (internal/modules/cjs/helpers.js:88:18)
3:59:26 PM: at Object. (/opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js:4:23)
3:59:26 PM: at Module._compile (internal/modules/cjs/loader.js:1063:30)
3:59:26 PM: at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
3:59:26 PM: at Module.load (internal/modules/cjs/loader.js:928:32)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
3:59:26 PM: at Module.require (internal/modules/cjs/loader.js:952:19)
3:59:26 PM: at require (internal/modules/cjs/helpers.js:88:18)
3:59:26 PM: at Object. (/opt/build/repo/node_modules/cheerio/src/index.ts:18:1)
3:59:26 PM: at Module._compile (internal/modules/cjs/loader.js:1063:30)
3:59:26 PM: at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
3:59:26 PM: at Module.load (internal/modules/cjs/loader.js:928:32)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
3:59:26 PM: code: ‘MODULE_NOT_FOUND’,
3:59:26 PM: requireStack: [
3:59:26 PM: ‘/opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/cheerio/dist/commonjs/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby-remark-images/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plugin.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/services/initialize.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/services/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/commands/build.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/cli.js’
3:59:26 PM: ]
3:59:26 PM: }
3:59:26 PM: Error: Cannot find module ‘node:stream’
3:59:26 PM: Require stack:
3:59:26 PM: - /opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js
3:59:26 PM: - /opt/build/repo/node_modules/cheerio/dist/commonjs/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby-remark-copy-linked-files/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plugin.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
3:59:26 PM: - /opt/build/repo/node_modules/gatsby/cli.js
3:59:26 PM: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
3:59:26 PM: at Module.require (internal/modules/cjs/loader.js:952:19)
3:59:26 PM: at require (internal/modules/cjs/helpers.js:88:18)
3:59:26 PM: at Object. (/opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js:4:23)
3:59:26 PM: at Module._compile (internal/modules/cjs/loader.js:1063:30)
3:59:26 PM: at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
3:59:26 PM: at Module.load (internal/modules/cjs/loader.js:928:32)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
3:59:26 PM: at Module.require (internal/modules/cjs/loader.js:952:19)
3:59:26 PM: at require (internal/modules/cjs/helpers.js:88:18)
3:59:26 PM: at Object. (/opt/build/repo/node_modules/cheerio/src/index.ts:18:1)
3:59:26 PM: at Module._compile (internal/modules/cjs/loader.js:1063:30)
3:59:26 PM: at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
3:59:26 PM: at Module.load (internal/modules/cjs/loader.js:928:32)
3:59:26 PM: at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
3:59:26 PM: code: ‘MODULE_NOT_FOUND’,
3:59:26 PM: requireStack: [
3:59:26 PM: ‘/opt/build/repo/node_modules/parse5-parser-stream/dist/cjs/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/cheerio/dist/commonjs/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby-remark-copy-linked-files/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plugin.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/services/initialize.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/services/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/commands/build.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js’,
3:59:26 PM: ‘/opt/build/repo/node_modules/gatsby/cli.js’
3:59:26 PM: ]
3:59:26 PM: }
3:59:26 PM: warning Plugin gatsby-plugin-netlify-identity is not compatible with your gatsby version 4.25.8 - It requires gatsby@^2.0.0
3:59:26 PM: success load plugins - 0.760s
3:59:26 PM: warning gatsby-plugin-react-helmet: Gatsby now has built-in support for modifying the document head. Learn more at Gatsby Head API | Gatsby
3:59:26 PM: success onPreInit - 0.006s
3:59:26 PM: success initialize cache - 0.044s
3:59:26 PM: success copy gatsby files - 0.094s
3:59:27 PM: success Compiling Gatsby Functions - 0.209s
3:59:27 PM: success onPreBootstrap - 0.216s
3:59:27 PM: error “gatsby-transformer-remark” threw an error while running the createSchemaCustomization lifecycle:
3:59:27 PM: Cannot read property ‘createSchemaCustomization’ of undefined
3:59:27 PM:
3:59:27 PM:
3:59:27 PM: TypeError: Cannot read property ‘createSchemaCustomization’ of undefined
3:59:27 PM:
3:59:27 PM: - create-schema-customization.js:47
3:59:27 PM: [repo]/[gatsby-transformer-remark]/create-schema-customization.js:47:31
3:59:27 PM:
3:59:27 PM: - Array.forEach
3:59:27 PM:
3:59:27 PM: - create-schema-customization.js:44 Object.module.exports [as createSchemaCust omization]
3:59:27 PM: [repo]/[gatsby-transformer-remark]/create-schema-customization.js:44:11
3:59:27 PM:
3:59:27 PM: - api-runner-node.js:487 runAPI
3:59:27 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:487:22
3:59:27 PM:
3:59:27 PM: - api-runner-node.js:638 Promise.catch.decorateEvent.pluginName
3:59:27 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:638:13
3:59:27 PM:
3:59:27 PM: - debuggability.js:384 Promise._execute
3:59:27 PM: [repo]/[bluebird]/js/release/debuggability.js:384:9
3:59:27 PM:
3:59:27 PM: - promise.js:518 Promise._resolveFromExecutor
3:59:27 PM: [repo]/[bluebird]/js/release/promise.js:518:18
3:59:27 PM:
3:59:27 PM: - promise.js:103 new Promise
3:59:27 PM: [repo]/[bluebird]/js/release/promise.js:103:10
3:59:27 PM:
3:59:27 PM: - api-runner-node.js:636
3:59:27 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:636:16
3:59:27 PM:
3:59:27 PM: - util.js:16 tryCatcher
3:59:27 PM: [repo]/[bluebird]/js/release/util.js:16:23
3:59:27 PM:
3:59:27 PM: - reduce.js:166 Object.gotValue
3:59:27 PM: [repo]/[bluebird]/js/release/reduce.js:166:18
3:59:27 PM:
3:59:27 PM: - reduce.js:155 Object.gotAccum
3:59:27 PM: [repo]/[bluebird]/js/release/reduce.js:155:25
3:59:27 PM:
3:59:27 PM: - util.js:16 Object.tryCatcher
3:59:27 PM: [repo]/[bluebird]/js/release/util.js:16:23
3:59:27 PM:
3:59:27 PM: - promise.js:547 Promise._settlePromiseFromHandler
3:59:27 PM: [repo]/[bluebird]/js/release/promise.js:547:31
3:59:27 PM:
3:59:27 PM: - promise.js:604 Promise._settlePromise
3:59:27 PM: [repo]/[bluebird]/js/release/promise.js:604:18
3:59:27 PM:
3:59:27 PM: - promise.js:649 Promise._settlePromise0
3:59:27 PM: [repo]/[bluebird]/js/release/promise.js:649:10
3:59:27 PM:
3:59:27 PM:
3:59:27 PM: not finished createSchemaCustomization - 0.376s
3:59:30 PM: npm ERR! code ELIFECYCLE
3:59:30 PM: npm ERR! errno 1
3:59:30 PM: npm ERR! gatsby-starter-decap-cms@1.1.3 build: npm run clean && gatsby build
3:59:30 PM: npm ERR! Exit status 1
3:59:30 PM: npm ERR!
3:59:30 PM: npm ERR! Failed at the gatsby-starter-decap-cms@1.1.3 build script.
3:59:30 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
3:59:30 PM: npm ERR! A complete log of this run can be found in:
3:59:30 PM: npm ERR! /opt/buildhome/.npm/_logs/2024-09-09T19_59_30_926Z-debug.log
3:59:31 PM: ​
3:59:31 PM: “build.command” failed
3:59:31 PM: ────────────────────────────────────────────────────────────────
3:59:31 PM: ​
3:59:31 PM: Error message
3:59:31 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
3:59:31 PM: ​
3:59:31 PM: Error location
3:59:31 PM: In build.command from netlify.toml:
3:59:31 PM: npm run build
3:59:31 PM: ​
3:59:31 PM: Resolved config
3:59:31 PM: build:
3:59:31 PM: command: npm run build
3:59:31 PM: commandOrigin: config
3:59:31 PM: environment:
3:59:31 PM: - NODE_VERSION
3:59:31 PM: - YARN_VERSION
3:59:31 PM: - YARN_FLAGS
3:59:31 PM: publish: /opt/build/repo/public
3:59:31 PM: publishOrigin: config
3:59:31 PM: functionsDirectory: /opt/build/repo/netlify/functions
3:59:31 PM: plugins:
3:59:31 PM: - inputs: {}
3:59:31 PM: origin: ui
3:59:31 PM: package: ‘@netlify/plugin-gatsby’
3:59:36 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
3:59:36 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:59:36 PM: Failing build: Failed to build site
3:59:36 PM: Finished processing build request in 2m5.821s

They are not the same module.

What your project wants:
https://nodejs.org/api/stream.html

What you tried to install:
https://www.npmjs.com/package/node-stream

I can’t advise what node version you’re running, as you’ve not provided the full build log.

You should ensure your build is running the correct node version, see this documentation:
https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

Thank you Nathan!

Just an update, I was able to build it successfully by building the site with a newer version of node. I think the version that I was using was outdated and does not come with the node:stream module.
I changed the node version in netlify.toml and the build was successful.

Thanks again for your reply.