Hello all
I am having an issue with the build failing. The error I am getting is that it cannot resolve module (local component) in MDX file in a gatsby site (vigorous-einstein-f9b279.netlify.app) which works fine when running gatsby build locally.
The error message
Can’t resolve ‘…/…/…/…/src/components/ReadMore/index’ in ‘/opt/build/repo/.cache/caches/gatsby-plugin-mdx/mdx-scopes-dir’
here is a snippet of the log
7:35:39 PM: Build ready to start
7:35:41 PM: build-image version: 73def8bb10593b9b818f44989a75ea508018ccb7 (focal)
7:35:41 PM: build-image tag: v4.5.2
7:35:41 PM: buildbot version: 8cd320132979d1a1a502e85e77b47b97cc7d659f
7:35:44 PM: Building without cache
7:35:44 PM: Starting to prepare the repo for build
7:35:44 PM: No cached dependencies found. Cloning fresh repo
7:35:44 PM: git clone https://github.com/gabroun/malikgabroun
7:35:46 PM: Preparing Git Reference refs/heads/updates
7:35:47 PM: Parsing package.json dependencies
7:35:48 PM: Starting build script
7:35:48 PM: Installing dependencies
7:35:48 PM: Python version set to 2.7
7:35:48 PM: Downloading and installing node v17.3.1...
7:35:49 PM: Downloading https://nodejs.org/dist/v17.3.1/node-v17.3.1-linux-x64.tar.xz...
7:35:49 PM: Computing checksum with sha256sum
7:35:49 PM: Checksums matched!
7:35:53 PM: Now using node v17.3.1 (npm v8.3.0)
7:35:53 PM: Started restoring cached build plugins
7:35:53 PM: Finished restoring cached build plugins
7:35:53 PM: Attempting ruby version 2.7.2, read from environment
7:35:54 PM: Using ruby version 2.7.2
7:35:54 PM: Using PHP version 8.0
7:35:54 PM: Started restoring cached yarn cache
7:35:54 PM: Finished restoring cached yarn cache
7:35:55 PM: Found yarn version (1.22.10) that doesn't match expected (1.3.2)
7:35:55 PM: up to date, audited 1 package in 256ms
7:35:55 PM: found 0 vulnerabilities
7:35:55 PM: Installing yarn at version 1.3.2
7:35:55 PM: Installing Yarn!
7:35:55 PM: > Downloading tarball...
7:35:55 PM: [1/2]: https://yarnpkg.com/downloads/1.3.2/yarn-v1.3.2.tar.gz --> /tmp/yarn.tar.gz.VJP5EFwdvs
7:35:55 PM: % Total % Received % Xferd Average Speed Time Time Time Current
7:35:55 PM: Dload Upload Total Spent Left Speed
7:35:55 PM: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
7:35:56 PM: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
7:35:56 PM: 100 77 100 77 0 0 326 0 --:--:-- --:--:-- --:--:-- 324
7:35:56 PM: 100 91 100 91 0 0 212 0 --:--:-- --:--:-- --:--:-- 212
7:35:56 PM: 100 655 100 655 0 0 1051 0 --:--:-- --:--:-- --:--:-- 1051
7:35:56 PM: 100 865k 100 865k 0 0 1034k 0 --:--:-- --:--:-- --:--:-- 1034k
7:35:56 PM: [2/2]: https://yarnpkg.com/downloads/1.3.2/yarn-v1.3.2.tar.gz.asc --> /tmp/yarn.tar.gz.VJP5EFwdvs.asc
7:35:56 PM: % Total % Received % Xferd Average Speed Time Time Time Current
7:35:56 PM: Dload Upload Total Spent Left Speed
7:35:56 PM: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
7:35:56 PM: 100 81 100 81 0 0 1396 0 --:--:-- --:--:-- --:--:-- 1396
7:35:56 PM: 100 95 100 95 0 0 1104 0 --:--:-- --:--:-- --:--:-- 1104
7:35:56 PM: 100 659 100 659 0 0 3765 0 --:--:-- --:--:-- --:--:-- 3765
7:35:56 PM: 100 1027 100 1027 0 0 3875 0 --:--:-- --:--:-- --:--:-- 3875
7:35:56 PM: > Verifying integrity...
7:35:56 PM: gpg: Signature made Thu 02 Nov 2017 04:44:10 PM UTC
7:35:56 PM: gpg: using RSA key 6A010C5166006599AA17F08146C2130DFD2497F5
7:35:56 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>" [unknown]
7:35:56 PM: gpg: Note: This key has expired!
7:35:56 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907 BBB7 1646 B01B 86E5 0310
7:35:56 PM: Subkey fingerprint: 6A01 0C51 6600 6599 AA17 F081 46C2 130D FD24 97F5
7:35:56 PM: > GPG signature looks good
7:35:56 PM: > Extracting to ~/.yarn...
7:35:56 PM: > Adding to $PATH...
7:35:57 PM: > Successfully installed Yarn 1.3.2! Please open another terminal where the `yarn` command will now be available.
7:35:57 PM: No yarn workspaces detected
7:35:57 PM: Started restoring cached node modules
7:35:57 PM: Finished restoring cached node modules
7:35:57 PM: Installing NPM modules using Yarn version 1.3.2
7:35:58 PM: yarn install v1.3.2
7:35:58 PM: (node:1444) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
7:35:58 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
7:35:58 PM: [1/4] Resolving packages...
7:35:59 PM: [2/4] Fetching packages...
7:36:28 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
7:36:28 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:36:28 PM: [3/4] Linking dependencies...
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "@types/webpack@4.x".
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "sockjs-client@^1.4.0".
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "type-fest@^0.13.1".
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "webpack-dev-server@3.x".
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "webpack-hot-middleware@2.x".
7:36:28 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.4.3" has unmet peer dependency "webpack-plugin-serve@0.x || 1.x".
7:36:28 PM: warning " > babel-loader@8.2.3" has unmet peer dependency "webpack@>=2".
7:36:28 PM: warning "gatsby > eslint-config-react-app@6.0.0" has incorrect peer dependency "@typescript-eslint/eslint-plugin@^4.0.0".
7:36:28 PM: warning "gatsby > eslint-config-react-app@6.0.0" has incorrect peer dependency "@typescript-eslint/parser@^4.0.0".
7:36:28 PM: warning "gatsby > eslint-config-react-app@6.0.0" has unmet peer dependency "babel-eslint@^10.0.0".
7:36:28 PM: warning "gatsby > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-jest@^24.0.0".
7:36:28 PM: warning "gatsby > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-testing-library@^3.9.0".
7:36:28 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".
7:36:28 PM: warning "gatsby > terser-webpack-plugin > terser@5.10.0" has unmet peer dependency "acorn@^8.5.0".
7:36:28 PM: warning "gatsby > socket.io > engine.io > ws@7.4.6" has unmet peer dependency "bufferutil@^4.0.1".
7:36:28 PM: warning "gatsby > socket.io > engine.io > ws@7.4.6" has unmet peer dependency "utf-8-validate@^5.0.2".
7:36:28 PM: warning "gatsby > eslint-plugin-graphql > graphql-config > @endemolshinegroup/cosmiconfig-typescript-loader > ts-node@9.1.1" has unmet peer dependency "typescript@>=2.7".
7:36:28 PM: warning "gatsby > eslint-plugin-graphql > graphql-config > @graphql-tools/url-loader > meros@1.1.4" has unmet peer dependency "@types/node@>=12".
7:36:28 PM: warning "gatsby > eslint-plugin-graphql > graphql-config > @graphql-tools/url-loader > ws@7.4.5" has unmet peer dependency "bufferutil@^4.0.1".
7:36:28 PM: warning "gatsby > eslint-plugin-graphql > graphql-config > @graphql-tools/url-loader > ws@7.4.5" has unmet peer dependency "utf-8-validate@^5.0.2".
7:36:28 PM: warning "gatsby-plugin-webpack-bundle-analyser-v2 > webpack-bundle-analyzer > ws@7.5.6" has unmet peer dependency "bufferutil@^4.0.1".
7:36:28 PM: warning "gatsby-plugin-webpack-bundle-analyser-v2 > webpack-bundle-analyzer > ws@7.5.6" has unmet peer dependency "utf-8-validate@^5.0.2".
7:36:28 PM: warning " > gatsby-plugin-mdx-embed@0.0.22" has incorrect peer dependency "gatsby@^3.2.0".
7:36:28 PM: warning " > gatsby-plugin-mdx-embed@0.0.22" has incorrect peer dependency "react@^16.9.0".
7:36:28 PM: warning " > gatsby-plugin-mdx-embed@0.0.22" has incorrect peer dependency "react-dom@^16.9.0".
7:36:28 PM: warning " > gatsby-plugin-mdx-prismjs@1.0.4" has incorrect peer dependency "gatsby@^1.0.0".
7:36:28 PM: warning " > gatsby-plugin-netlify@3.14.0" has incorrect peer dependency "gatsby@^3.0.0".
7:36:28 PM: warning "gatsby-plugin-netlify > webpack-assets-manifest@5.0.6" has unmet peer dependency "webpack@^5.2.0".
7:36:28 PM: warning " > mdx-embed@0.0.22" has incorrect peer dependency "react@^16.9.0".
7:36:28 PM: warning " > mdx-embed@0.0.22" has incorrect peer dependency "react-dom@^16.9.0".
7:36:28 PM: warning " > styled-components@5.3.3" has unmet peer dependency "react-is@>= 16.8.0".
7:36:28 PM: warning " > cypress-axe@0.14.0" has unmet peer dependency "axe-core@^3 || ^4".
7:36:28 PM: warning " > eslint-plugin-prettier@4.0.0" has unmet peer dependency "prettier@>=2.0.0".
7:36:28 PM: warning " > jest@27.4.7" has unmet peer dependency "node-notifier@^8.0.1 || ^9.0.0 || ^10.0.0".
7:36:28 PM: warning "jest > @jest/core@27.4.7" has unmet peer dependency "node-notifier@^8.0.1 || ^9.0.0 || ^10.0.0".
7:36:28 PM: warning "jest > jest-cli@27.4.7" has unmet peer dependency "node-notifier@^8.0.1 || ^9.0.0 || ^10.0.0".
7:36:28 PM: warning "jest > @jest/core > @jest/reporters@27.4.6" has unmet peer dependency "node-notifier@^8.0.1 || ^9.0.0 || ^10.0.0".
7:36:28 PM: warning "jest > @jest/core > jest-config@27.4.7" has unmet peer dependency "ts-node@>=9.0.0".
7:36:28 PM: warning "jest > @jest/core > jest-config > jest-environment-jsdom > jsdom@16.7.0" has unmet peer dependency "canvas@^2.5.0".
7:36:49 PM: [4/4] Building fresh packages...
7:37:08 PM: Done in 70.08s.
7:37:08 PM: NPM modules installed using Yarn
7:37:08 PM: (node:1758) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
7:37:08 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
7:37:08 PM: Started restoring cached go cache
7:37:08 PM: Finished restoring cached go cache
7:37:08 PM: Installing Go version 1.10
7:37:13 PM: unset GOOS;
7:37:13 PM: unset GOARCH;
7:37:13 PM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';
7:37:13 PM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}";
7:37:13 PM: go version >&2;
7:37:13 PM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env"
7:37:13 PM: go version go1.10 linux/amd64
7:37:13 PM: Installing missing commands
7:37:13 PM: Verify run directory
7:37:15 PM:
7:37:15 PM: ────────────────────────────────────────────────────────────────
7:37:15 PM: Netlify Build
7:37:15 PM: ────────────────────────────────────────────────────────────────
7:37:15 PM:
7:37:15 PM: ❯ Version
7:37:15 PM: @netlify/build 26.2.0
7:37:15 PM:
7:37:15 PM: ❯ Flags
7:37:15 PM: baseRelDir: false
7:37:15 PM: buildId: 61ec5c8bb0f7b676d8039161
7:37:15 PM: deployId: 61ec5c8bb0f7b676d8039163
7:37:15 PM:
7:37:15 PM: ❯ Current directory
7:37:15 PM: /opt/build/repo
7:37:15 PM:
7:37:15 PM: ❯ Config file
7:37:15 PM: No config file was defined: using default values.
7:37:15 PM:
7:37:15 PM: ❯ Context
7:37:15 PM: production
7:37:15 PM:
7:37:15 PM: ────────────────────────────────────────────────────────────────
7:37:15 PM: 1. Build command from Netlify app
7:37:15 PM: ────────────────────────────────────────────────────────────────
7:37:15 PM:
7:37:15 PM: $ gatsby build
7:37:18 PM: warning Plugin gatsby-plugin-mdx-embed is not compatible with your gatsby version 4.5.0 - It requires gatsby@^3.2.0
7:37:19 PM: warning Plugin gatsby-plugin-mdx-embed is not compatible with your gatsby version 4.5.0 - It requires gatsby@^3.2.0
7:37:19 PM: success open and validate gatsby-configs, load plugins - 1.736s
7:37:19 PM: success onPreInit - 0.005s
7:37:19 PM: success initialize cache - 0.256s
7:37:19 PM: success copy gatsby files - 0.084s
7:37:20 PM: success Compiling Gatsby Functions - 0.377s
7:37:20 PM: success onPreBootstrap - 0.394s
7:37:20 PM: success createSchemaCustomization - 0.010s
7:37:48 PM: success Checking for changed pages - 0.000s
7:37:48 PM: success source and transform nodes - 28.144s
7:37:48 PM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
7:37:49 PM: success building schema - 0.881s
7:37:49 PM: success createPages - 0.104s
7:37:49 PM: success createPagesStatefully - 0.154s
7:37:49 PM: info Total nodes: 341, SitePage nodes: 26 (use --verbose for breakdown)
7:37:49 PM: success Checking for changed pages - 0.000s
7:37:49 PM: success onPreExtractQueries - 0.000s
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: (Use `node --trace-warnings ...` to show where the warning was created)
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:54 PM: error (node:1866) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [PassThrough]. Use emitter.setMaxListeners() to increase limit
7:37:56 PM: success extract queries from components - 6.569s
7:37:56 PM: warning The GraphQL query in the non-page component "/opt/build/repo/src/templates/projectTemplate.js" will not be run.
7:37:56 PM: Exported queries are only executed for Page components. It's possible you're
7:37:56 PM: trying to create pages in your gatsby-node.js and that's failing for somereason.
7:37:56 PM: If the failing component(s) is a regular component and not intended to be a page
7:37:56 PM: component, you generally want to use a <StaticQuery> (https://gatsbyjs.org/docs/static-query)
7:37:56 PM: instead of exporting a page query.
7:37:56 PM: If you're more experienced with GraphQL, you can also export GraphQLfragments from components and compose the fragments in the Page component
7:37:56 PM: query and pass data down into the child component — https://graphql.org/learn/queries/#fragments
7:37:56 PM: success write out redirect data - 0.104s
7:37:56 PM: success Build manifest and related icons - 0.002s
7:37:56 PM: success onPostBootstrap - 0.022s
7:37:56 PM: info bootstrap finished - 40.994s
7:37:56 PM: success write out requires - 0.254s
7:39:04 PM: failed Building production JavaScript and CSS bundles - 68.371s
7:39:04 PM: error Generating JavaScript bundles failed
7:39:04 PM: Can't resolve '../../../../src/components/ReadMore/index' in '/opt/build/repo/.cache/caches/gatsby-plugin-mdx/mdx-scopes-dir'
7:39:04 PM: If you're trying to use a package make sure that '../../../../src/components/ReadMore/index' is installed. If you're trying to use a local file make sure that the path is correct.
7:39:04 PM: not finished Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 99.146s
7:39:05 PM:
7:39:05 PM: ────────────────────────────────────────────────────────────────
7:39:05 PM: "build.command" failed
7:39:05 PM: ────────────────────────────────────────────────────────────────
7:39:05 PM:
7:39:05 PM: Error message
7:39:05 PM: Command failed with exit code 1: gatsby build
7:39:05 PM:
7:39:05 PM: Error location
7:39:05 PM: In Build command from Netlify app:
7:39:05 PM: gatsby build
7:39:05 PM:
7:39:05 PM: Resolved config
7:39:05 PM: build:
7:39:05 PM: command: gatsby build
7:39:05 PM: commandOrigin: ui
7:39:05 PM: environment:
7:39:05 PM: - GA_TRACKINGID
7:39:05 PM: - NETLIFY_USE_YARN
7:39:05 PM: - NODE_VERSION
7:39:05 PM: publish: /opt/build/repo/public
7:39:05 PM: publishOrigin: ui
7:39:05 PM: Caching artifacts
7:39:05 PM: Started saving node modules
7:39:05 PM: Finished saving node modules
7:39:05 PM: Started saving build plugins
7:39:05 PM: Finished saving build plugins
7:39:05 PM: Started saving yarn cache
7:39:13 PM: Finished saving yarn cache
7:39:13 PM: Started saving pip cache
7:39:13 PM: Finished saving pip cache
7:39:13 PM: Started saving emacs cask dependencies
7:39:13 PM: Finished saving emacs cask dependencies
7:39:13 PM: Started saving maven dependencies
7:39:13 PM: Finished saving maven dependencies
7:39:13 PM: Started saving boot dependencies
7:39:14 PM: Finished saving boot dependencies
7:39:14 PM: Started saving rust rustup cache
7:39:14 PM: Finished saving rust rustup cache
7:39:14 PM: Started saving go dependencies
7:39:15 PM: Finished saving go dependencies
7:39:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:39:18 PM: Creating deploy upload records
7:39:18 PM: Failing build: Failed to build site
7:39:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
7:39:19 PM: Finished processing build request in 3m37.272489214s
and here is the variations I tried in MDX file and pushed to try and deploy but failed in all attempts
import ReadMore from "../../../src/components/ReadMore/index";
import ReadMore from "../src/components/ReadMore/index";
import ReadMore from "components/ReadMore/index";
import ReadMore from "@components/ReadMore/index"; (I have a custom alias defined in webpack config)
here is my gatsby-node webpack config
exports.onCreateWebpackConfig = ({ stage, actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
"@components": path.resolve(__dirname, "src/components"),
"@static": path.resolve(__dirname, "static"),
"@utils": path.resolve(__dirname, "src/utils"),
"@resources": path.resolve(__dirname, "src/resources"),
"@hooks": path.resolve(__dirname, "src/hooks"),
"@styles": path.resolve(__dirname, "src/styles"),
},
// modules: [path.resolve(__dirname, "src"), "node_modules"],
},
});
if (stage === "develop") {
actions.setWebpackConfig({
devtool: "cheap-module-source-map",
});
}
};
One thing I am noticing when I put the relative path is that in the build logs its adding extra “…/” which is different from the code
Folder structure
├── src
│ ├── components
│ ├── ReadMore
│ ├── index.js
├── content
│ ├── posts
│ ├── index.mdx
Thanks for the help