Build Deploys Fail - Can't Find module after many troubleshooting attempts

Hello!

2:09:29 PM: Build ready to start
2:09:31 PM: build-image version: 3bcb38c35508b42e9121d4badfe6d8c66fd7a3f0
2:09:31 PM: build-image tag: v4.3.2
2:09:31 PM: buildbot version: 050f5e521c0d810d56330c3a7d48687a1932379d
2:09:32 PM: Fetching cached dependencies
2:09:32 PM: Failed to fetch cache, continuing with build
2:09:32 PM: Starting to prepare the repo for build
2:09:32 PM: No cached dependencies found. Cloning fresh repo
2:09:32 PM: git clone https://github.com/zanewolf/ocean_affinity_group
2:09:33 PM: Preparing Git Reference refs/heads/main
2:09:34 PM: Parsing package.json dependencies
2:09:35 PM: Starting build script
2:09:35 PM: Installing dependencies
2:09:35 PM: Python version set to 2.7
2:09:36 PM: v16.10.0 is already installed.
2:09:36 PM: Now using node v16.10.0 (npm v7.24.0)
2:09:36 PM: Started restoring cached build plugins
2:09:36 PM: Finished restoring cached build plugins
2:09:36 PM: Attempting ruby version 2.7.2, read from environment
2:09:38 PM: Using ruby version 2.7.2
2:09:38 PM: Using PHP version 8.0
2:09:38 PM: Started restoring cached yarn cache
2:09:38 PM: Finished restoring cached yarn cache
2:09:38 PM: Installing yarn at version 1.22.10
2:09:38 PM: Installing Yarn!
2:09:38 PM: > Downloading tarball...
2:09:38 PM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz --> /tmp/yarn.tar.gz.u96GI1GU76
2:09:38 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2:09:38 PM:                                  Dload  Upload   Total   Spent    Left  Speed
2:09:38 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2:09:38 PM: 100    81  100    81    0     0    430      0 --:--:-- --:--:-- --:--:--   430
2:09:39 PM: 100    95  100    95    0     0    232      0 --:--:-- --:--:-- --:--:--   232
2:09:39 PM: 100   626  100   626    0     0   1242      0 --:--:-- --:--:-- --:--:--  1242
2:09:39 PM:  10 1215k   10  127k    0     0   220k      0  0:00:05 --:--:--  0:00:05  220k
2:09:39 PM: 100 1215k  100 1215k    0     0  1993k      0 --:--:-- --:--:-- --:--:-- 35.4M
2:09:39 PM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc --> /tmp/yarn.tar.gz.u96GI1GU76.asc
2:09:39 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2:09:39 PM:                                  Dload  Upload   Total   Spent    Left  Speed
2:09:39 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2:09:39 PM: 100    85  100    85    0     0   1888      0 --:--:-- --:--:-- --:--:--  1888
2:09:39 PM: 100    99  100    99    0     0   1302      0 --:--:-- --:--:-- --:--:--  1302
2:09:39 PM: 100   630  100   630    0     0   6176      0 --:--:-- --:--:-- --:--:--  6176
2:09:39 PM: 100   832  100   832    0     0   7362      0 --:--:-- --:--:-- --:--:--  7362
2:09:39 PM: > Verifying integrity...
2:09:39 PM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC
2:09:39 PM: gpg:                using RSA key 6D98490C6F1ACDDD448E45954F77679369475BAA
2:09:39 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>" [unknown]
2:09:39 PM: gpg: WARNING: This key is not certified with a trusted signature!
2:09:39 PM: gpg:          There is no indication that the signature belongs to the owner.
2:09:39 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
2:09:39 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
2:09:39 PM: > GPG signature looks good
2:09:39 PM: > Extracting to ~/.yarn...
2:09:39 PM: > Adding to $PATH...
2:09:40 PM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
2:09:40 PM: No yarn workspaces detected
2:09:40 PM: Started restoring cached node modules
2:09:40 PM: Finished restoring cached node modules
2:09:40 PM: Installing NPM modules using Yarn version 1.22.10
2:09:41 PM: yarn install v1.22.10
2:09:41 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
2:09:41 PM: [1/4] Resolving packages...
2:09:42 PM: warning react-snap-scroll > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
2:09:43 PM: [2/4] Fetching packages...
2:10:29 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
2:10:29 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
2:10:29 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
2:10:29 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
2:10:29 PM: [3/4] Linking dependencies...
2:10:29 PM: warning " > flexbox-react@4.4.0" has unmet peer dependency "prop-types@*".
2:10:29 PM: warning "flexbox-react > styled-components@2.4.1" has incorrect peer dependency "react@>= 0.14.0 < 17.0.0-0".
2:10:29 PM: warning "gatsby > eslint-config-react-app@6.0.0" has unmet peer dependency "babel-eslint@^10.0.0".
2:10:29 PM: warning "gatsby > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
2:10:29 PM: warning "react-snap-scroll > @babel/plugin-proposal-class-properties@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
2:10:29 PM: warning "gatsby > eslint-plugin-graphql > graphql-config > @endemolshinegroup/cosmiconfig-typescript-loader > ts-node@9.1.1" has unmet peer dependency "typescript@>=2.7".
2:10:29 PM: warning " > gatsby-plugin-gatsby-cloud@3.2.0" has unmet peer dependency "webpack@*".
2:10:29 PM: warning "gatsby-plugin-gatsby-cloud > webpack-assets-manifest@5.0.6" has unmet peer dependency "webpack@^5.2.0".
2:10:29 PM: warning " > gatsby-plugin-image@1.14.1" has unmet peer dependency "@babel/core@^7.12.3".
2:10:29 PM: warning " > gatsby-plugin-mdx@2.14.0" has unmet peer dependency "@mdx-js/mdx@^1.0.0".
2:10:29 PM: warning " > gatsby-plugin-mdx@2.14.0" has unmet peer dependency "@mdx-js/react@^1.0.0".
2:10:29 PM: warning " > gatsby-remark-prismjs@5.7.0" has unmet peer dependency "prismjs@^1.15.0".
2:10:29 PM: warning "netlify-cms-app > netlify-cms-core > react-markdown@6.0.3" has unmet peer dependency "@types/react@>=16".
2:10:29 PM: warning "netlify-cms-app > netlify-cms-widget-code > react-codemirror2@7.2.1" has incorrect peer dependency "react@>=15.5 <=16.x".
2:10:29 PM: warning "netlify-cms-app > netlify-cms-core > redux-notifications > react-redux@4.4.10" has incorrect peer dependency "redux@^2.0.0 || ^3.0.0".
2:10:29 PM: warning " > react-snap-scroll@0.0.5" has incorrect peer dependency "react@^16.7.0".
2:10:29 PM: warning " > styled-components@5.3.0" has unmet peer dependency "react-is@>= 16.8.0".
2:10:29 PM: warning Workspaces can only be enabled in private projects.
2:10:55 PM: [4/4] Building fresh packages...
2:11:03 PM: success Saved lockfile.
2:11:03 PM: Done in 82.59s.
2:11:04 PM: NPM modules installed using Yarn
2:11:04 PM: Started restoring cached go cache
2:11:04 PM: Finished restoring cached go cache
2:11:04 PM: go version go1.16.5 linux/amd64
2:11:04 PM: go version go1.16.5 linux/amd64
2:11:04 PM: Installing missing commands
2:11:04 PM: Verify run directory
2:11:05 PM: ​
2:11:05 PM: ────────────────────────────────────────────────────────────────
2:11:05 PM:   Netlify Build                                                 
2:11:05 PM: ────────────────────────────────────────────────────────────────
2:11:05 PM: ​
2:11:05 PM: ❯ Version
2:11:05 PM:   @netlify/build 18.13.9
2:11:05 PM: ​
2:11:05 PM: ❯ Flags
2:11:05 PM:   baseRelDir: true
2:11:05 PM:   buildId: 615de659f8a889000721f7f0
2:11:05 PM:   deployId: 615de659f8a889000721f7f2
2:11:05 PM: ​
2:11:05 PM: ❯ Current directory
2:11:05 PM:   /opt/build/repo
2:11:05 PM: ​
2:11:05 PM: ❯ Config file
2:11:05 PM:   No config file was defined: using default values.
2:11:05 PM: ​
2:11:05 PM: ❯ Context
2:11:05 PM:   production
2:11:06 PM: ​
2:11:06 PM: ❯ Installing plugins
2:11:06 PM:    - @netlify/plugin-gatsby@1.0.3
2:11:13 PM: ​
2:11:13 PM: ❯ Loading plugins
2:11:13 PM:    - @netlify/plugin-gatsby@1.0.3 from Netlify app
2:11:13 PM: ​
2:11:13 PM: ────────────────────────────────────────────────────────────────
2:11:13 PM:   1. onPreBuild command from @netlify/plugin-gatsby             
2:11:13 PM: ────────────────────────────────────────────────────────────────
2:11:13 PM: ​
2:11:14 PM: No Gatsby cache found. Building fresh.
2:11:14 PM: ​
2:11:14 PM: (@netlify/plugin-gatsby onPreBuild completed in 314ms)
2:11:14 PM: ​
2:11:14 PM: ────────────────────────────────────────────────────────────────
2:11:14 PM:   2. Build command from Netlify app                             
2:11:14 PM: ────────────────────────────────────────────────────────────────
2:11:14 PM: ​
2:11:14 PM: $ gatsby build
2:11:17 PM: error Error in "/opt/build/repo/node_modules/gatsby-plugin-mdx/gatsby-node.js": Cannot find module '@mdx-js/mdx'
2:11:17 PM: Require stack:
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-plugin-mdx/utils/mdx.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-plugin-mdx/utils/create-mdx-node.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-plugin-mdx/gatsby/on-create-node.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-plugin-mdx/gatsby-node.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config-and-plugins.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-cli/lib/create-cli.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby-cli/lib/index.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
2:11:17 PM: - /opt/build/repo/node_modules/gatsby/cli.js
2:11:17 PM: 
2:11:17 PM: 
2:11:17 PM:   Error: Cannot find module '@mdx-js/mdx'
2:11:17 PM:   Require stack:
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-plugin-mdx/utils/mdx.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-plugin-mdx/utils/create-mdx-node.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-plugin-mdx/gatsby/on-create-node.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-plugin-mdx/gatsby-node.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js  - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config-and-plugins.j  s
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/index.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-cli/lib/create-cli.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby-cli/lib/index.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
2:11:17 PM:   - /opt/build/repo/node_modules/gatsby/cli.js
2:11:17 PM:   
2:11:17 PM:   - loader:933 Function.Module._resolveFilename
2:11:17 PM:     node:internal/modules/cjs/loader:933:15
2:11:17 PM:   
2:11:17 PM:   - loader:778 Function.Module._load
2:11:17 PM:     node:internal/modules/cjs/loader:778:27
2:11:17 PM:   
2:11:17 PM:   - loader:1005 Module.require
2:11:17 PM:     node:internal/modules/cjs/loader:1005:19
2:11:17 PM:   
2:11:17 PM:   - v8-compile-cache.js:159 require
2:11:17 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:159:20
2:11:17 PM:   
2:11:17 PM:   - mdx.js:1 Object.<anonymous>
2:11:17 PM:     [repo]/[gatsby-plugin-mdx]/utils/mdx.js:1:75
2:11:17 PM:   
2:11:17 PM:   - v8-compile-cache.js:192 Module._compile
2:11:17 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:192:30
2:11:17 PM:   
2:11:17 PM:   - loader:1153 Object.Module._extensions..js
2:11:17 PM:     node:internal/modules/cjs/loader:1153:10
2:11:17 PM:   
2:11:17 PM:   - loader:981 Module.load
2:11:17 PM:     node:internal/modules/cjs/loader:981:32
2:11:17 PM:   
2:11:17 PM:   - loader:822 Function.Module._load
2:11:17 PM:     node:internal/modules/cjs/loader:822:12
2:11:17 PM:   
2:11:17 PM:   - loader:1005 Module.require
2:11:17 PM:     node:internal/modules/cjs/loader:1005:19
2:11:17 PM:   
2:11:17 PM:   - v8-compile-cache.js:159 require
2:11:17 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:159:20
2:11:17 PM:   
2:11:17 PM:   - create-mdx-node.js:3 Object.<anonymous>
2:11:17 PM:     [repo]/[gatsby-plugin-mdx]/utils/create-mdx-node.js:3:13
2:11:17 PM:   
2:11:17 PM:   - v8-compile-cache.js:192 Module._compile
2:11:17 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:192:30
2:11:17 PM:   
2:11:17 PM:   - loader:1153 Object.Module._extensions..js
2:11:17 PM:     node:internal/modules/cjs/loader:1153:10
2:11:17 PM:   
2:11:17 PM:   - loader:981 Module.load
2:11:17 PM:     node:internal/modules/cjs/loader:981:32
2:11:17 PM:   
2:11:17 PM:   - loader:822 Function.Module._load
2:11:17 PM:     node:internal/modules/cjs/loader:822:12
2:11:17 PM:   
2:11:17 PM: 
2:11:17 PM: not finished open and validate gatsby-configs, load plugins - 1.028s
2:11:17 PM: ​
2:11:17 PM: ────────────────────────────────────────────────────────────────
2:11:17 PM:   "build.command" failed                                        
2:11:17 PM: ────────────────────────────────────────────────────────────────
2:11:17 PM: ​
2:11:17 PM:   Error message
2:11:17 PM:   Command failed with exit code 1: gatsby build
2:11:17 PM: ​
2:11:17 PM:   Error location
2:11:17 PM:   In Build command from Netlify app:
2:11:17 PM:   gatsby build
2:11:17 PM: ​
2:11:18 PM:   Resolved config
2:11:18 PM:   build:
2:11:18 PM:     command: gatsby build
2:11:18 PM:     commandOrigin: ui
2:11:18 PM:     environment:
2:11:18 PM:       - GATSBY_AIRTABLE_API_KEY
2:11:18 PM:       - GATSBY_AIRTABLE_TABLE_ID
2:11:18 PM:     publish: /opt/build/repo/public
2:11:18 PM:     publishOrigin: ui
2:11:18 PM:   plugins:
2:11:18 PM:     - inputs: {}
2:11:18 PM:       origin: ui
2:11:18 PM:       package: '@netlify/plugin-gatsby'
2:11:18 PM: Caching artifacts
2:11:18 PM: Started saving node modules
2:11:18 PM: Finished saving node modules
2:11:18 PM: Started saving build plugins
2:11:18 PM: Finished saving build plugins
2:11:18 PM: Started saving yarn cache
2:11:28 PM: Finished saving yarn cache
2:11:28 PM: Started saving pip cache
2:11:28 PM: Finished saving pip cache
2:11:28 PM: Started saving emacs cask dependencies
2:11:28 PM: Finished saving emacs cask dependencies
2:11:28 PM: Started saving maven dependencies
2:11:28 PM: Finished saving maven dependencies
2:11:28 PM: Started saving boot dependencies
2:11:28 PM: Finished saving boot dependencies
2:11:28 PM: Started saving rust rustup cache
2:11:28 PM: Finished saving rust rustup cache
2:11:28 PM: Started saving go dependencies
2:11:28 PM: Finished saving go dependencies
2:11:30 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:11:30 PM: Creating deploy upload records
2:11:30 PM: Failing build: Failed to build site
2:11:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
2:11:30 PM: Finished processing build request in 1m58.910349249s

I have updated gatsby, I have updated npm, I have updated individual plugins (including gatsby-plugin-mdx), I have set the node version (I think, node -v > nvmrc), I have tried yarn build/gatsby build/npm run build and all error out. I have tried deploying to Gatsby Cloud - same error. I have tried adding node_modules to the git repo, and then deleted it and added it back to .gitignore.

I have no idea what else to try. Please help?

Hi. Try to change the environment variable value so that it builds successfully. Follow the steps below:

=> Go to Deploy settings.
=> Click on Environment and then click Edit Variables button.
=> Set Key to CI and Value to false.
=> Now click on the Save button.

Now you can build and deploy your project without getting the error.

1 Like

Dang. You were so confident that I really expected it to work. Nope. Same error. :confused:

does this build locally?

Hi Perry - yes, it does.

Okay, I’m going to try downloading a gatsby starter site and see if that deploys. If it does, I’ll add in my site components and then see how that goes and if that deploys. Fingers’ crossed.

Do you have this module in your package.json? If it exists in devDependencies, try adding it to dependencies and try again.

What do you know! @mdx-js/* modules were present in package-lock.json but not package.json. Added them and then that error went away! I’m a little confused as to how that could happen, but on to another error for now. Got a lot further into the build before this popped up:

Should I open another thread?

Clearing the cache and redeploying did not work.

yes please do open another thread and respond here to link the two as it is as separate issue. thanks for asking.

Done! New Thread

Thanks!
Z