Hey Netlifiers,
I’m getting the following build error when building my next.js app from inside my monorepo. 3:57:49 PM: npm ERR! Cannot set properties of null (setting 'dev')
. I have a working build with a slightly different configuration (see below) and the only difference between them, is that I changed the base directory to my next.js apps subdirectory (/apps/app
) and I change directory before running the build command. (hence the cd ../.. &&
).
site-name: consistently-space
url: https://consistently.space
Monorepo structure
apps/
├─ app/
│ ├─ package.json
│ ├─ netlify.toml
├─ server/
packages/
├─ shared/
│ ├─ package.json
package.json
turbo.json
This configuration yields the error
Deployment
This configuration yields
3:57:49 PM: npm ERR! Cannot set properties of null (setting 'dev')
This configuration works but doesn’t respect netlify.toml at /apps/app
Image of the working Configuration.
I couldn’t add the image because new users are limited to one embed per post
With this configuration I need to put the
netlify.toml
at the root of the repo. This makes it impossible to have different configurations for different netlify hosted apps in my repo. So it’s not desired.
I would like to achieve the following thing:
My goal with this config is tell netlify to see /apps/app
as the base directory of my app so it uses the netlify.toml in this folder. But it shouldn’t run the build command from inside /apps/app
.
It should build from the root of the repo (/
). I need to run the build command at the root of the repo because this triggers turborepo’s build command from the root package.json which also builds the dependency of my next.js app (packages/shared
).
Does someone have an idea what could cause this problem? Or alternatively, is there another way to tell netlify where to look for the netlify.toml without setting the base directory?
Entire buildlog
3:57:24 PM: build-image version: 6c82004ef0368b3a0232c6837cead23188bb347e (focal)
3:57:24 PM: buildbot version: 0dfbdb6e6e614fd26450cfc6bacb47c4c6fd9626
3:57:24 PM: Building without cache
3:57:24 PM: Starting to prepare the repo for build
3:57:24 PM: No cached dependencies found. Cloning fresh repo
3:57:24 PM: git clone --filter=blob:none https://github.com/DATADEER/consistently.space_nextjs
3:57:25 PM: Preparing Git Reference refs/heads/switch-to-monorepo
3:57:25 PM: Parsing package.json dependencies
3:57:26 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'apps/app' versus '/apps/app' in the Netlify UI
3:57:26 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'apps/app/.next' versus '.next' in the Netlify UI
3:57:27 PM: Starting to install dependencies
3:57:27 PM: Using PHP version 8.0
3:57:27 PM: Started restoring cached go cache
3:57:27 PM: Finished restoring cached go cache
3:57:27 PM: Installing Go version 1.19.5 (requested 1.19.5)
3:57:31 PM: go version go1.19.5 linux/amd64
3:57:32 PM: v16.20.0 is already installed.
3:57:32 PM: Now using node v16.20.0 (npm v8.19.4)
3:57:32 PM: Enabling Node.js Corepack
3:57:32 PM: Started restoring cached build plugins
3:57:32 PM: Finished restoring cached build plugins
3:57:32 PM: Started restoring cached corepack dependencies
3:57:32 PM: Finished restoring cached corepack dependencies
3:57:32 PM: npm workspaces detected
3:57:33 PM: Installing npm packages using npm version 8.19.4
3:57:35 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
3:57:36 PM: npm WARN deprecated xmldom@0.1.31: Deprecated due to CVE-2021-21366 resolved in 0.5.0
3:57:36 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
3:57:37 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
3:57:37 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
3:57:39 PM: npm WARN deprecated @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
3:57:40 PM: npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
3:57:40 PM: npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
3:57:41 PM: npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
3:57:49 PM: npm ERR! Cannot set properties of null (setting 'dev')
3:57:49 PM: npm ERR! A complete log of this run can be found in:
3:57:49 PM: npm ERR! /opt/buildhome/.npm/_logs/2023-04-01T13_57_33_382Z-debug-0.log
3:57:49 PM: Error during npm install
3:57:49 PM: Build was terminated: dependency_installation script returned non-zero exit code: 1
3:57:50 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
3:57:49 PM: Failing build: Failed to install dependencies
3:57:50 PM: Finished processing build request in 25.927s