Absolute Paths not recognized in Build Deployment --> Site crashes

Hi,

My site name: luxury-crisp-4c6313 keeps crashing on deployment because it does not recognize the absolute paths i’ve set on jsconfig.json.

Here is the whole build log for reading experience:

9:55:30 AM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
9:55:30 AM: build-image tag: v4.16.3
9:55:30 AM: buildbot version: 211709fe0bb687fe4fe2ebbb0a0d7258aa6e265c
9:55:30 AM: Fetching cached dependencies
9:55:30 AM: Failed to fetch cache, continuing with build
9:55:30 AM: Starting to prepare the repo for build
9:55:30 AM: No cached dependencies found. Cloning fresh repo
9:55:30 AM: git clone --filter=blob:none --no-checkout https://github.com/otsolap/pasmiini.fi
9:55:30 AM: Preparing Git Reference refs/heads/main
9:55:32 AM: Parsing package.json dependencies
9:55:33 AM: Starting build script
9:55:33 AM: Installing dependencies
9:55:33 AM: Python version set to 2.7
9:55:34 AM: v16.19.0 is already installed.
9:55:34 AM: Now using node v16.19.0 (npm v8.19.3)
9:55:34 AM: Enabling Node.js Corepack
9:55:34 AM: Started restoring cached build plugins
9:55:34 AM: Finished restoring cached build plugins
9:55:34 AM: Attempting Ruby version 2.7.2, read from environment
9:55:35 AM: Using Ruby version 2.7.2
9:55:35 AM: Using PHP version 8.0
9:55:35 AM: Started restoring cached corepack dependencies
9:55:35 AM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
9:55:35 AM: Finished restoring cached corepack dependencies
9:55:35 AM: No npm workspaces detected
9:55:35 AM: Started restoring cached node modules
9:55:35 AM: Finished restoring cached node modules
9:55:35 AM: Bypassing sha validation. Running pre & post install scripts
9:55:35 AM: Installing npm packages using npm version 8.19.3
9:55:36 AM: npm WARN old lockfile
9:55:36 AM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
9:55:36 AM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
9:55:36 AM: npm WARN old lockfile
9:55:36 AM: npm WARN old lockfile This is a one-time fix-up, please be patient...
9:55:36 AM: npm WARN old lockfile
9:55:44 AM: added 220 packages, and audited 221 packages in 8s
9:55:44 AM: 38 packages are looking for funding
9:55:44 AM:   run `npm fund` for details
9:55:44 AM: found 0 vulnerabilities
9:55:44 AM: npm packages installed
9:55:44 AM: Started restoring cached go cache
9:55:44 AM: Finished restoring cached go cache
9:55:45 AM: Installing Go version 1.19.5 (requested 1.19.x)
9:55:50 AM: unset GOOS;
9:55:50 AM: unset GOARCH;
9:55:50 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.19.5.linux.amd64';
9:55:50 AM: export PATH="/opt/buildhome/.gimme/versions/go1.19.5.linux.amd64/bin:${PATH}";
9:55:50 AM: go version >&2;
9:55:50 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.19.5.linux.amd64.env"
9:55:50 AM: go version go1.19.5 linux/amd64
9:55:50 AM: Detected 1 framework(s)
9:55:50 AM: "next" at version "13.1.4"
9:55:50 AM: Installing missing commands
9:55:50 AM: Verify run directory
9:55:50 AM: Section completed: initializing
9:55:52 AM: ​
9:55:52 AM:   Netlify Build                                                 
9:55:52 AM: ────────────────────────────────────────────────────────────────
9:55:52 AM: ​
9:55:52 AM: ❯ Version
9:55:52 AM:   @netlify/build 29.5.1
9:55:52 AM: ​
9:55:52 AM: ❯ Flags
9:55:52 AM:   baseRelDir: true
9:55:52 AM:   buildId: 63cd0810d826d70009be1324
9:55:52 AM:   deployId: 63cd0810d826d70009be1326
9:55:52 AM: ​
9:55:52 AM: ❯ Current directory
9:55:52 AM:   /opt/build/repo
9:55:52 AM: ​
9:55:52 AM: ❯ Config file
9:55:52 AM:   /opt/build/repo/netlify.toml
9:55:52 AM: ​
9:55:52 AM: ❯ Context
9:55:52 AM:   production
9:55:52 AM: ​
9:55:52 AM: ❯ Using Next.js Runtime - v4.30.0
9:55:53 AM: ​
9:55:53 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
9:55:53 AM: ────────────────────────────────────────────────────────────────
9:55:53 AM: ​
9:55:53 AM: No Next.js cache to restore.
9:55:53 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
9:55:53 AM: ​
9:55:53 AM: (@netlify/plugin-nextjs onPreBuild completed in 17ms)
9:55:53 AM: ​
9:55:53 AM:   2. build.command from netlify.toml                            
9:55:53 AM: ────────────────────────────────────────────────────────────────
9:55:53 AM: ​
9:55:53 AM: $ npm run build
9:55:53 AM: > Pasmiini@0.1.0 build
9:55:53 AM: > next build
9:55:54 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
9:55:54 AM: info  - Linting and checking validity of types...
9:55:55 AM: info  - Creating an optimized production build...
9:56:00 AM: Failed to compile.
9:56:00 AM: 
9:56:00 AM: ./components/ServiceCarousel.js
9:56:00 AM: Module not found: Can't resolve '@partials/YoutubeEmbed'
9:56:00 AM: Import trace for requested module:
9:56:00 AM: ./pages/index.js
9:56:00 AM: https://nextjs.org/docs/messages/module-not-found
9:56:00 AM: ./components/Textarea.js
9:56:00 AM: Module not found: Can't resolve '@partials/MarkdownBlock'
9:56:00 AM: Import trace for requested module:
9:56:00 AM: ./pages/jasmiini.js
9:56:00 AM: https://nextjs.org/docs/messages/module-not-found
9:56:00 AM: ./pages/_app.js
9:56:00 AM: Module not found: Can't resolve '@components/Layout'
9:56:00 AM: https://nextjs.org/docs/messages/module-not-found
9:56:00 AM: ./pages/_app.js
9:56:00 AM: Module not found: Can't resolve '@components/navigation/Header'
9:56:00 AM: https://nextjs.org/docs/messages/module-not-found
9:56:00 AM: ./pages/_app.js
9:56:00 AM: Module not found: Can't resolve '@components/navigation/Footer'
9:56:00 AM: https://nextjs.org/docs/messages/module-not-found
9:56:00 AM: > Build failed because of webpack errors
9:56:00 AM: ​
9:56:00 AM:   "build.command" failed                                        
9:56:00 AM: ────────────────────────────────────────────────────────────────
9:56:00 AM: ​
9:56:00 AM:   Error message
9:56:00 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:56:00 AM: ​
9:56:00 AM:   Error location
9:56:02 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:56:00 AM:   In build.command from netlify.toml:
9:56:00 AM:   npm run build
9:56:00 AM: ​
9:56:00 AM:   Resolved config
9:56:00 AM:   build:
9:56:00 AM:     command: npm run build
9:56:00 AM:     commandOrigin: config
9:56:00 AM:     environment:
9:56:00 AM:       - NEXT_PRIVATE_TARGET
9:56:00 AM:     publish: /opt/build/repo/.next
9:56:00 AM:     publishOrigin: config
9:56:00 AM:   plugins:
9:56:00 AM:     - inputs: {}
9:56:00 AM:       origin: config
9:56:00 AM:       package: '@netlify/plugin-nextjs'
9:56:01 AM: Caching artifacts
9:56:01 AM: Started saving node modules
9:56:01 AM: Finished saving node modules
9:56:01 AM: Started saving build plugins
9:56:01 AM: Finished saving build plugins
9:56:01 AM: Started saving pip cache
9:56:01 AM: Finished saving pip cache
9:56:01 AM: Started saving emacs cask dependencies
9:56:01 AM: Finished saving emacs cask dependencies
9:56:01 AM: Started saving maven dependencies
9:56:01 AM: Finished saving maven dependencies
9:56:01 AM: Started saving boot dependencies
9:56:01 AM: Finished saving boot dependencies
9:56:01 AM: Started saving rust rustup cache
9:56:01 AM: Finished saving rust rustup cache
9:56:01 AM: Started saving go dependencies
9:56:01 AM: Finished saving go dependencies
9:56:01 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:56:02 AM: Failing build: Failed to build site
9:56:02 AM: Finished processing build request in 32.01s

Could someone take a better look at what might be the problem here? Here is the repo for the project too: GitHub - otsolap/pasmiini.fi: Business portoflio of a occupational therapist. Build with NextJS and NetlifyCMS

I’m unable to build your site locally as well. The errors are different, but I believe there are some issues with the repo anyways that you should try fixing first. After fixing the paths for .json, latest error is:

Error occurred prerendering page "/palvelut/mallituote". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedmallituote.json'

Error occurred prerendering page "/palvelut". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/palvelut.js:69:74)
    at renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:26)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-2". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-2.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-6_1". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-6_1.json'

Error occurred prerendering page "/blogi/miten-maarittelet-onnellisuutesi". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedmiten-maarittelet-onnellisuutesi.json'

Error occurred prerendering page "/blogi/syomishairio-2". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-2.json'

Error occurred prerendering page "/blogi/syomishairio-3". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-3.json'

Error occurred prerendering page "/blogi/syomishairio-4". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-4.json'

Error occurred prerendering page "/blogi/syomishairio-5". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-5.json'

Error occurred prerendering page "/blogi/syomishairio-6". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-6.json'

Error occurred prerendering page "/blogi/syomishairio". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-4". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-4.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-3". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-3.json'

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/index.js:336:102)
    at async renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)

Error occurred prerendering page "/blogi/kuidut-vatsan-ja-suoliston-toiminnan-tukena". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedkuidut-vatsan-ja-suoliston-toiminnan-tukena.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-6". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-6.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-5". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-5.json'
[=   ] info  - Generating static pages (20/23)
Error occurred prerendering page "/blogi". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/blogi.js:148:82)
    at async renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
info  - Generating static pages (23/23)

> Build error occurred
Error: Export encountered errors on following paths:
        /
        /blogi
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-2
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-3
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-4
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-5
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-6
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-6_1
        /blogi/[slug]: /blogi/kuidut-vatsan-ja-suoliston-toiminnan-tukena
        /blogi/[slug]: /blogi/miten-maarittelet-onnellisuutesi
        /blogi/[slug]: /blogi/syomishairio
        /blogi/[slug]: /blogi/syomishairio-2
        /blogi/[slug]: /blogi/syomishairio-3
        /blogi/[slug]: /blogi/syomishairio-4
        /blogi/[slug]: /blogi/syomishairio-5
        /blogi/[slug]: /blogi/syomishairio-6
        /palvelut
        /palvelut/[slug]: /palvelut/mallituote
    at /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/index.js:409:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:1398:21
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:1258:17
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async Object.build [as default] (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:66:29)
1 Like

Hi,

So how did you fix the paths for .json? If you could kindly explain that I can move forward and see what the problems are with my slug builders.

PS. For me the local development environment works. I am using Node 16.13.2 fo my local development and my computer is a Thinkpad XL.

The paths were like: ../../content/pages/treenit.json, I just changed it to: ../content/pages/treenit.json.

No that wasn’t my problem. That problem you fixed was honestly my own stupidity and I apologize for that. I left some gits uncommited and that’s why there was a problem. That path however has nothing to do with NextJS absolute paths.

Here I pushed the fixes myself and here is stil the same problem:

5:17:50 PM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
5:17:50 PM: build-image tag: v4.16.3
5:17:50 PM: buildbot version: 211709fe0bb687fe4fe2ebbb0a0d7258aa6e265c
5:17:50 PM: Fetching cached dependencies
5:17:50 PM: Failed to fetch cache, continuing with build
5:17:50 PM: Starting to prepare the repo for build
5:17:50 PM: No cached dependencies found. Cloning fresh repo
5:17:50 PM: git clone --filter=blob:none --no-checkout https://github.com/otsolap/pasmiini.fi
5:17:50 PM: Preparing Git Reference refs/heads/main
5:17:52 PM: Parsing package.json dependencies
5:17:53 PM: Starting build script
5:17:53 PM: Installing dependencies
5:17:53 PM: Python version set to 2.7
5:17:54 PM: v16.19.0 is already installed.
5:17:54 PM: Now using node v16.19.0 (npm v8.19.3)
5:17:54 PM: Enabling Node.js Corepack
5:17:54 PM: Started restoring cached build plugins
5:17:54 PM: Finished restoring cached build plugins
5:17:54 PM: Attempting Ruby version 2.7.2, read from environment
5:17:55 PM: Using Ruby version 2.7.2
5:17:55 PM: Using PHP version 8.0
5:17:55 PM: Started restoring cached corepack dependencies
5:17:55 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
5:17:55 PM: Finished restoring cached corepack dependencies
5:17:55 PM: No npm workspaces detected
5:17:55 PM: Started restoring cached node modules
5:17:55 PM: Finished restoring cached node modules
5:17:55 PM: Bypassing sha validation. Running pre & post install scripts
5:17:55 PM: Installing npm packages using npm version 8.19.3
5:18:01 PM: added 221 packages, and audited 222 packages in 6s
5:18:01 PM: 39 packages are looking for funding
5:18:01 PM:   run `npm fund` for details
5:18:01 PM: found 0 vulnerabilities
5:18:01 PM: npm packages installed
5:18:02 PM: Started restoring cached go cache
5:18:02 PM: Finished restoring cached go cache
5:18:03 PM: Installing Go version 1.19.5 (requested 1.19.x)
5:18:07 PM: unset GOOS;
5:18:07 PM: unset GOARCH;
5:18:07 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.19.5.linux.amd64';
5:18:07 PM: export PATH="/opt/buildhome/.gimme/versions/go1.19.5.linux.amd64/bin:${PATH}";
5:18:07 PM: go version >&2;
5:18:07 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.19.5.linux.amd64.env"
5:18:07 PM: go version go1.19.5 linux/amd64
5:18:08 PM: Detected 1 framework(s)
5:18:08 PM: "next" at version "13.1.4"
5:18:08 PM: Installing missing commands
5:18:08 PM: Verify run directory
5:18:08 PM: Section completed: initializing
5:18:09 PM: ​
5:18:09 PM:   Netlify Build                                                 
5:18:09 PM: ────────────────────────────────────────────────────────────────
5:18:09 PM: ​
5:18:09 PM: ❯ Version
5:18:09 PM:   @netlify/build 29.5.1
5:18:09 PM: ​
5:18:09 PM: ❯ Flags
5:18:09 PM:   baseRelDir: true
5:18:09 PM:   buildId: 63cd6fbc88603e0008fd12fc
5:18:09 PM:   deployId: 63cd6fbc88603e0008fd12fe
5:18:09 PM: ​
5:18:09 PM: ❯ Current directory
5:18:09 PM:   /opt/build/repo
5:18:09 PM: ​
5:18:09 PM: ❯ Config file
5:18:09 PM:   /opt/build/repo/netlify.toml
5:18:09 PM: ​
5:18:09 PM: ❯ Context
5:18:09 PM:   production
5:18:09 PM: ​
5:18:09 PM: ❯ Using Next.js Runtime - v4.30.0
5:18:11 PM: ​
5:18:11 PM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
5:18:11 PM: ────────────────────────────────────────────────────────────────
5:18:11 PM: ​
5:18:11 PM: No Next.js cache to restore.
5:18:11 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
5:18:11 PM: ​
5:18:11 PM: (@netlify/plugin-nextjs onPreBuild completed in 17ms)
5:18:11 PM: ​
5:18:11 PM:   2. build.command from netlify.toml                            
5:18:11 PM: ────────────────────────────────────────────────────────────────
5:18:11 PM: ​
5:18:11 PM: $ npm run build
5:18:11 PM: > Pasmiini@0.1.0 build
5:18:11 PM: > next build
5:18:11 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
5:18:11 PM: info  - Linting and checking validity of types...
5:18:12 PM: info  - Creating an optimized production build...
5:18:18 PM: Failed to compile.
5:18:18 PM: 
5:18:18 PM: ./components/ServiceCarousel.js
5:18:18 PM: Module not found: Can't resolve '@partials/YoutubeEmbed'
5:18:18 PM: Import trace for requested module:
5:18:18 PM: ./pages/index.js
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./components/Textarea.js
5:18:18 PM: Module not found: Can't resolve '@partials/MarkdownBlock'
5:18:18 PM: Import trace for requested module:
5:18:18 PM: ./pages/index.js
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/Layout'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/navigation/Header'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/navigation/Footer'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: > Build failed because of webpack errors
5:18:18 PM: ​
5:18:18 PM:   "build.command" failed                                        
5:18:18 PM: ────────────────────────────────────────────────────────────────
5:18:18 PM: ​
5:18:18 PM:   Error message
5:18:18 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
5:18:18 PM: ​
5:18:18 PM:   Error location
5:18:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:18:18 PM:   In build.command from netlify.toml:
5:18:18 PM:   npm run build
5:18:18 PM: ​
5:18:18 PM:   Resolved config
5:18:18 PM:   build:
5:18:18 PM:     command: npm run build
5:18:18 PM:     commandOrigin: config
5:18:18 PM:     environment:
5:18:18 PM:       - NEXT_PRIVATE_TARGET
5:18:18 PM:     publish: /opt/build/repo/.next
5:18:18 PM:     publishOrigin: config
5:18:18 PM:   plugins:
5:18:18 PM:     - inputs: {}
5:18:18 PM:       origin: config
5:18:18 PM:       package: '@netlify/plugin-nextjs'
5:18:18 PM: Caching artifacts
5:18:18 PM: Started saving node modules
5:18:18 PM: Finished saving node modules
5:18:18 PM: Started saving build plugins
5:18:18 PM: Finished saving build plugins
5:18:18 PM: Started saving pip cache
5:18:18 PM: Finished saving pip cache
5:18:18 PM: Started saving emacs cask dependencies
5:18:18 PM: Finished saving emacs cask dependencies
5:18:18 PM: Started saving maven dependencies
5:18:18 PM: Finished saving maven dependencies
5:18:18 PM: Started saving boot dependencies
5:18:18 PM: Finished saving boot dependencies
5:18:18 PM: Started saving rust rustup cache
5:18:18 PM: Finished saving rust rustup cache
5:18:18 PM: Started saving go dependencies
5:18:18 PM: Finished saving go dependencies
5:18:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:18:19 PM: Failing build: Failed to build site
5:18:19 PM: Finished processing build request in 28.925s

Now specifically I am asking about this part:

5:18:18 PM: ./components/ServiceCarousel.js
5:18:18 PM: Module not found: Can't resolve '@partials/YoutubeEmbed'
5:18:18 PM: Import trace for requested module:
5:18:18 PM: ./pages/index.js
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./components/Textarea.js
5:18:18 PM: Module not found: Can't resolve '@partials/MarkdownBlock'
5:18:18 PM: Import trace for requested module:
5:18:18 PM: ./pages/index.js
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/Layout'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/navigation/Header'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: ./pages/_app.js
5:18:18 PM: Module not found: Can't resolve '@components/navigation/Footer'
5:18:18 PM: https://nextjs.org/docs/messages/module-not-found
5:18:18 PM: > Build failed because of webpack errors
5:18:18 PM: ​
5:18:18 PM:   "build.command" failed                                        
5:18:18 PM: ─────────────────────────────

For some reason it cannot recognize my @partials shortcuts which are set on jsconfig.json file. This my problem when trying to publish on netlify.

Yes, but like I mentioned, I’m unable to get to that point on my system. The site build fails on my local system (outside of Netlify environment), with the errors I’ve shown. I can’t confirm if your repo is working outside of Netlify.

If you fetch my latest updates your local working environment should work. I apologyze for that. =) Could you try giving it a new spin?

I deleted the local folder and cloned your repo again, only to run into the same issue again, I’m afraid. Here’s the full log if it helps:

npm run build

> Pasmiini@0.1.0 build
> next build

info  - Linting and checking validity of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data  
[    ] info  - Generating static pages (0/23)
Error occurred prerendering page "/palvelut/mallituote". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedmallituote.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-6_1". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-6_1.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako.json'

Error occurred prerendering page "/blogi/kuidut-vatsan-ja-suoliston-toiminnan-tukena". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedkuidut-vatsan-ja-suoliston-toiminnan-tukena.json'

Error occurred prerendering page "/blogi/miten-maarittelet-onnellisuutesi". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedmiten-maarittelet-onnellisuutesi.json'

Error occurred prerendering page "/blogi/syomishairio-2". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-2.json'

Error occurred prerendering page "/blogi/syomishairio-3". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-3.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-2". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-2.json'

Error occurred prerendering page "/blogi/syomishairio-4". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-4.json'

Error occurred prerendering page "/blogi/syomishairio-5". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-5.json'

Error occurred prerendering page "/blogi/syomishairio-6". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio-6.json'

Error occurred prerendering page "/blogi/syomishairio". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedsyomishairio.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-3". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-3.json'
[==  ] info  - Generating static pages (14/23)
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/index.js:336:102)
    at async renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-4". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-4.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-6". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-6.json'

Error occurred prerendering page "/blogi/istumatyolainen-vasyttaako-5". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, open 'undefinedistumatyolainen-vasyttaako-5.json'
[ ===] info  - Generating static pages (21/23)
Error occurred prerendering page "/palvelut". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/palvelut.js:67:74)
    at renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:26)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)

Error occurred prerendering page "/blogi". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdir (node:internal/fs/promises:724:10)
    at getStaticProps (/Users/hrishikesh/Desktop/pasmiini.fi/.next/server/pages/blogi.js:148:82)
    at async renderToHTML (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/server/render.js:385:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/worker.js:277:36
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
info  - Generating static pages (23/23)

> Build error occurred
Error: Export encountered errors on following paths:
        /
        /blogi
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-2
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-3
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-4
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-5
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-6
        /blogi/[slug]: /blogi/istumatyolainen-vasyttaako-6_1
        /blogi/[slug]: /blogi/kuidut-vatsan-ja-suoliston-toiminnan-tukena
        /blogi/[slug]: /blogi/miten-maarittelet-onnellisuutesi
        /blogi/[slug]: /blogi/syomishairio
        /blogi/[slug]: /blogi/syomishairio-2
        /blogi/[slug]: /blogi/syomishairio-3
        /blogi/[slug]: /blogi/syomishairio-4
        /blogi/[slug]: /blogi/syomishairio-5
        /blogi/[slug]: /blogi/syomishairio-6
        /palvelut
        /palvelut/[slug]: /palvelut/mallituote
    at /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/export/index.js:409:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:1398:21
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async /Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:1258:17
    at async Span.traceAsyncFn (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/trace/trace.js:79:20)
    at async Object.build [as default] (/Users/hrishikesh/Desktop/pasmiini.fi/node_modules/next/dist/build/index.js:66:29)
1 Like

Well hey you don’t have my .env file, right?

Here you go:

`BLOG_DIR_PATH = './content/posts/'
SERVICE_DIR_PATH = './content/services/'
AUTHOR_DIR_PATH = './content/authors/'
ACCORDION_DIR_PATH = './content/accordionItems/'`

Add this to your project.

hey Hrishikesh you think you might have time to take a look at this today? =) Just add the .env file and your slugs should work.

Sorry for the delay. I should have seen this before, but apparently you’re facing this issue:

1 Like

This was it. Thank you!