Home
Support Forums

Getting Error while Deploying NextJS App to Netlify After Upgrading to NextJS v11

10:28:37 PM: Build ready to start
10:28:39 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
10:28:39 PM: build-image tag: v3.8.0
10:28:39 PM: buildbot version: fd2d744d8bfa914ebde93203088eebb12b66468e
10:28:39 PM: Fetching cached dependencies
10:28:39 PM: Starting to download cache of 277.9MB
10:28:41 PM: Finished downloading cache in 1.458363624s
10:28:41 PM: Starting to extract cache
10:28:51 PM: Finished extracting cache in 10.9573787s
10:28:52 PM: Finished fetching cache in 12.508995943s
10:28:52 PM: Starting to prepare the repo for build
10:28:52 PM: Preparing Git Reference refs/heads/main
10:28:59 PM: Parsing package.json dependencies
10:29:00 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'out' versus '' in the Netlify UI
10:29:00 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'next build' in the Netlify UI
10:29:00 PM: Starting build script
10:29:00 PM: Installing dependencies
10:29:00 PM: Python version set to 2.7
10:29:01 PM: Started restoring cached node version
10:29:03 PM: Finished restoring cached node version
10:29:04 PM: v12.18.0 is already installed.
10:29:05 PM: Now using node v12.18.0 (npm v6.14.4)
10:29:05 PM: Started restoring cached build plugins
10:29:05 PM: Finished restoring cached build plugins
10:29:05 PM: Attempting ruby version 2.7.1, read from environment
10:29:05 PM: Started restoring cached ruby version
10:29:05 PM: Finished restoring cached ruby version
10:29:07 PM: Using ruby version 2.7.1
10:29:08 PM: Using PHP version 5.6
10:29:08 PM: Started restoring cached node modules
10:29:08 PM: Finished restoring cached node modules
10:29:08 PM: Installing NPM modules using NPM version 6.14.4
10:29:18 PM: npm WARN react-sound@1.2.0 requires a peer of react@^15.3.0 || ^16.0.0-0 but none is installed. You must install peer dependencies yourself.
10:29:18 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
10:29:18 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:29:18 PM: added 41 packages from 59 contributors, removed 594 packages, updated 30 packages and audited 709 packages in 9.207s
10:29:18 PM: 58 packages are looking for funding
10:29:18 PM:   run `npm fund` for details
10:29:18 PM: found 3 moderate severity vulnerabilities
10:29:18 PM:   run `npm audit fix` to fix them, or `npm audit` for details
10:29:18 PM: NPM modules installed
10:29:19 PM: Started restoring cached go cache
10:29:19 PM: Finished restoring cached go cache
10:29:19 PM: go version go1.14.4 linux/amd64
10:29:19 PM: go version go1.14.4 linux/amd64
10:29:19 PM: Installing missing commands
10:29:19 PM: Verify run directory
10:29:19 PM: ​
10:29:19 PM: ────────────────────────────────────────────────────────────────
10:29:19 PM:   Netlify Build                                                 
10:29:19 PM: ────────────────────────────────────────────────────────────────
10:29:19 PM: ​
10:29:19 PM: ❯ Version
10:29:19 PM:   @netlify/build 15.11.5
10:29:19 PM: ​
10:29:19 PM: ❯ Flags
10:29:19 PM:   deployId: 60f08c6514d08a0008d78480
10:29:19 PM: ​
10:29:19 PM: ❯ Current directory
10:29:19 PM:   /opt/build/repo
10:29:19 PM: ​
10:29:19 PM: ❯ Config file
10:29:19 PM:   /opt/build/repo/netlify.toml
10:29:19 PM: ​
10:29:19 PM: ❯ Context
10:29:19 PM:   production
10:29:19 PM: ​
10:29:19 PM: ❯ Loading plugins
10:29:19 PM:    - @netlify/plugin-nextjs@3.7.0 from Netlify app
10:29:20 PM: ​
10:29:20 PM: ────────────────────────────────────────────────────────────────
10:29:20 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
10:29:20 PM: ────────────────────────────────────────────────────────────────
10:29:20 PM: ​
10:29:20 PM: Using Next.js 11.0.1
10:29:20 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:29:20 PM: The "target" config property must be one of "serverless", "experimental-serverless-trace". Building with "serverless" target.
10:29:21 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:29:22 PM: Next.js cache restored.
10:29:22 PM: ​
10:29:22 PM: (@netlify/plugin-nextjs onPreBuild completed in 1.9s)
10:29:22 PM: ​
10:29:22 PM: ────────────────────────────────────────────────────────────────
10:29:22 PM:   2. build.command from netlify.toml                            
10:29:22 PM: ────────────────────────────────────────────────────────────────
10:29:22 PM: ​
10:29:22 PM: $ npm run build
10:29:22 PM: > next-netlify-starter@0.5.0 build /opt/build/repo
10:29:22 PM: > next build
10:29:23 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:29:23 PM: info  - Checking validity of types...
10:30:02 PM: warn  - No ESLint configuration detected. Run next lint to begin setup
10:30:02 PM: info  - Creating an optimized production build...
10:30:53 PM: Failed to compile.
10:30:53 PM: 
10:30:53 PM: ModuleNotFoundError: Module not found: Error: Can't resolve 'arc-templates/dist/es5' in '/opt/build/repo/node_modules/consolidate/lib'
10:30:53 PM: > Build error occurred
10:30:53 PM: Error: > Build failed because of webpack errors
10:30:53 PM:     at /opt/build/repo/node_modules/next/dist/build/index.js:15:924
10:30:53 PM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/telemetry/trace/trace.js:6:584)
10:30:53 PM: npm ERR! code ELIFECYCLE
10:30:53 PM: npm ERR! errno 1
10:30:53 PM: npm ERR! next-netlify-starter@0.5.0 build: `next build`
10:30:53 PM: npm ERR! Exit status 1
10:30:53 PM: npm ERR!
10:30:53 PM: npm ERR! Failed at the next-netlify-starter@0.5.0 build script.
10:30:53 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:30:53 PM: npm ERR! A complete log of this run can be found in:
10:30:53 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-07-15T19_30_53_199Z-debug.log
10:30:53 PM: ​
10:30:53 PM: ────────────────────────────────────────────────────────────────
10:30:53 PM:   "build.command" failed                                        
10:30:53 PM: ────────────────────────────────────────────────────────────────
10:30:53 PM: ​
10:30:53 PM:   Error message
10:30:53 PM:   Command failed with exit code 1: npm run build
10:30:53 PM: ​
10:30:53 PM:   Error location
10:30:53 PM:   In build.command from netlify.toml:
10:30:53 PM:   npm run build
10:30:53 PM: ​
10:30:53 PM:   Resolved config
10:30:53 PM:   build:
10:30:53 PM:     command: npm run build
10:30:53 PM:     commandOrigin: config
10:30:53 PM:     environment:
10:30:53 PM:       - NEXT_PUBLIC_API_URL
10:30:53 PM:     publish: /opt/build/repo/out
10:30:53 PM:     publishOrigin: config
10:30:53 PM:   plugins:
10:30:53 PM:     - inputs: {}
10:30:53 PM:       origin: ui
10:30:53 PM:       package: '@netlify/plugin-nextjs'
10:30:53 PM: Caching artifacts
10:30:53 PM: Started saving node modules
10:30:53 PM: Finished saving node modules
10:30:53 PM: Started saving build plugins
10:30:53 PM: Finished saving build plugins
10:30:53 PM: Started saving pip cache
10:30:53 PM: Finished saving pip cache
10:30:53 PM: Creating deploy upload records
10:30:53 PM: Started saving emacs cask dependencies
10:30:54 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:30:53 PM: Finished saving emacs cask dependencies
10:30:53 PM: Started saving maven dependencies
10:30:53 PM: Finished saving maven dependencies
10:30:53 PM: Started saving boot dependencies
10:30:53 PM: Finished saving boot dependencies
10:30:53 PM: Started saving rust rustup cache
10:30:53 PM: Finished saving rust rustup cache
10:30:53 PM: Started saving go dependencies
10:30:53 PM: Finished saving go dependencies
10:30:53 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:30:54 PM: Failing build: Failed to build site
10:30:54 PM: Finished processing build request in 2m15.368550115s

Error:

10:30:53 PM: ModuleNotFoundError: Module not found: Error: Can't resolve 'arc-templates/dist/es5' in '/opt/build/repo/node_modules/consolidate/lib'

I am getting the error above when deploying app after updating NextJS to v11, which I do not get when running the app locally. My friend also is getting this error.

url : https://www.quranesk.com/ (it is hosting an old build version of the site)

Do you have this module: arc-templates - npm in your package.json?

i did but then it has the same error requiring velocityjs then i install it and it asks for another weird unrelated thing and i install it and so on…

There was recently a new version of the Netlify NextJS plugin that was released. Would you try updating it to the latest version if it’s not already?

1 Like

Yes I tried to reassemble the whole app based on next-netlify-starter and see what is causing the problem. i deployed next-netlify-starter app (official netlify template) and deployed it directly and it worked (meaning that it is using the latest plugin). Then as soon as I added my pages/api/graphql page which works on my local machine and the only external library it is using is the latest apollo-server-micro which is used in nextjhs apollo example, i get what seems like a memory leak.

(I removed unnecessary imports that i knew caused problems and i made it simple and all by apollo-server-micro)

12:41:50 AM: ────────────────────────────────────────────────────────────────
12:41:50 AM:   2. build.command from netlify.toml                            
12:41:50 AM: ────────────────────────────────────────────────────────────────
12:41:50 AM: ​
12:41:50 AM: $ npm run build
12:41:50 AM: > next-netlify-starter@0.5.0 build /opt/build/repo
12:41:50 AM: > next build
12:41:51 AM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
12:41:51 AM: info  - Checking validity of types...
12:41:54 AM: warn  - No ESLint configuration detected. Run next lint to begin setup
12:41:54 AM: info  - Creating an optimized production build...
12:42:06 AM: (node:1379) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
12:42:35 AM: <--- Last few GCs --->
12:42:35 AM: [1379:0x3200290]    44013 ms: Mark-sweep 1885.7 (1989.1) -> 1885.7 (1957.1) MB, 1280.0 / 0.0 ms  (average mu = 0.258, current mu = 0.000) last resort GC in old space requested
12:42:35 AM: [1379:0x3200290]    45156 ms: Mark-sweep 1885.7 (1957.1) -> 1885.6 (1956.9) MB, 1143.4 / 0.0 ms  (average mu = 0.152, current mu = 0.000) last resort GC in old space requested
12:42:35 AM: <--- JS stacktrace --->
12:42:35 AM: ==== JS stack trace =========================================
12:42:35 AM:     0: ExitFrame [pc: 0x13cb519]
12:42:35 AM: Security context: 0x2eee14dc08d1 <JSObject>
12:42:35 AM:     1: set [0x2eee14dca791](this=0x0ac5c9d9c161 <Map map = 0xceab4580899>,0x2fac62ff9e69 <Object map = 0xceab45b96e9>,4194310)
12:42:35 AM:     2: addReferenceable(aka addReferenceable) [0xac5c9d9c181] [/opt/build/repo/node_modules/next/dist/compiled/webpack/bundle5.js:~122784] [pc=0x368476cf3f09](this=0x142a2ccc04b1 <undefined>,0x2fac62ff9e69 <Object map = 0xceab45b96e9>)
12:42:35 AM:   ...
12:42:35 AM: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
12:42:35 AM:  1: 0xa07f90 node::Abort() [node]
12:42:35 AM:  2: 0xa0839c node::OnFatalError(char const*, char const*) [node]
12:42:35 AM:  3: 0xb80d9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
12:42:35 AM:  4: 0xb81119 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
12:42:35 AM:  5: 0xd2d875  [node]
12:42:35 AM:  6: 0xd3e188 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
12:42:35 AM:  7: 0xd0502d v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::RootIndex, int, v8::internal::Object, v8::internal::AllocationType) [node]
12:42:35 AM:  8: 0xd05120 v8::internal::Handle<v8::internal::FixedArray> v8::internal::Factory::NewFixedArrayWithMap<v8::internal::FixedArray>(v8::internal::RootIndex, int, v8::internal::AllocationType) [node]
12:42:35 AM:  9: 0xf33170 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Allocate(v8::internal::Isolate*, int, v8::internal::AllocationType) [node]
12:42:35 AM: 10: 0xf33221 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>, int) [node]
12:42:35 AM: 11: 0xf3386b v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::EnsureGrowable(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>) [node]
12:42:35 AM: 12: 0x1029ff8 v8::internal::Runtime_MapGrow(int, unsigned long*, v8::internal::Isolate*) [node]
12:42:35 AM: 13: 0x13cb519  [node]
12:42:35 AM: Aborted
12:42:35 AM: npm ERR! code ELIFECYCLE
12:42:35 AM: npm ERR! errno 134
12:42:35 AM: npm ERR! next-netlify-starter@0.5.0 build: `next build`
12:42:35 AM: npm ERR! Exit status 134
12:42:35 AM: npm ERR!
12:42:35 AM: npm ERR! Failed at the next-netlify-starter@0.5.0 build script.
12:42:35 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:42:35 AM: npm ERR! A complete log of this run can be found in:
12:42:35 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-07-16T21_42_35_781Z-debug.log
12:42:35 AM: ​
12:42:35 AM: ────────────────────────────────────────────────────────────────
12:42:35 AM:   "build.command" failed                                        
12:42:35 AM: ────────────────────────────────────────────────────────────────
12:42:35 AM: ​
12:42:35 AM:   Error message
12:42:35 AM:   Command failed with exit code 134: npm run build
12:42:35 AM: ​
12:42:35 AM:   Error location
12:42:35 AM:   In build.command from netlify.toml:
12:42:35 AM:   npm run build
12:42:35 AM: ​
12:42:35 AM:   Resolved config
12:42:35 AM:   build:
12:42:35 AM:     command: npm run build
12:42:35 AM:     commandOrigin: config
12:42:35 AM:     environment:
12:42:35 AM:       - NEXT_PUBLIC_API_URL
12:42:35 AM:     publish: /opt/build/repo/out
12:42:35 AM:     publishOrigin: config
12:42:35 AM:   plugins:
12:42:35 AM:     - inputs: {}
12:42:35 AM:       origin: ui
12:42:35 AM:       package: '@netlify/plugin-nextjs'
12:42:36 AM: Caching artifacts
12:42:36 AM: Started saving node modules
12:42:36 AM: Finished saving node modules
12:42:36 AM: Started saving build plugins
12:42:36 AM: Finished saving build plugins
12:42:36 AM: Started saving pip cache
12:42:36 AM: Finished saving pip cache
12:42:36 AM: Started saving emacs cask dependencies
12:42:36 AM: Finished saving emacs cask dependencies
12:42:36 AM: Started saving maven dependencies
12:42:36 AM: Finished saving maven dependencies
12:42:36 AM: Started saving boot dependencies
12:42:36 AM: Finished saving boot dependencies
12:42:36 AM: Started saving rust rustup cache
12:42:36 AM: Finished saving rust rustup cache
12:42:36 AM: Started saving go dependencies
12:42:36 AM: Finished saving go dependencies
12:42:36 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:42:36 AM: Creating deploy upload records
12:42:36 AM: Failing build: Failed to build site
12:42:36 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:42:36 AM: Finished processing build request in 1m11.429362536s```

github repo: https://github.com/HassanAlmus/next-netlify-starter

Hi @HassanAlmusabbih

You could try setting a flag as mentioned here: javascript - Node.js heap out of memory - Stack Overflow. Not sure if it would help as only 3GB RAM is assured when building. So, it might still fail. But, worth a try.