Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.0.8 breaks plugin (can't read config target) #104

Closed
laugharn opened this issue Mar 1, 2021 · 20 comments · Fixed by #105
Closed

10.0.8 breaks plugin (can't read config target) #104

laugharn opened this issue Mar 1, 2021 · 20 comments · Fixed by #105
Labels
priority: medium type: bug code to address defects in shipped code

Comments

@laugharn
Copy link

laugharn commented Mar 1, 2021

Describe the bug
We are experimenting with using netlify-plugin-nextjs instead of next-on-netlify in a yarn monorepo. Unfortunately, when we attempt to deploy with the plugin, we get a Your next.config.js must set the "target" property to one of: serverless, experimental-serverless-trace. Update the target property to allow this plugin to run. message. Attached are two screen shots, one of the next.config.js in question, and the second of the message:

image

image

As you can see from the message screenshot, it is console logging This file is detected based on the next.config.js console.log statement, so it sees the correct file. I can also confirm that this is working if we use next-on-netlify directly.

Expected behavior
Successful deployment

Versions

  • Next.js: 10.0.8-canary.10
  • plugin (if installed at fixed version): @netlify/plugin-nextjs@2.0.1 via UI install
@lindsaylevine
Copy link

@laugharn hey dan! this seems like possibly a monorepo-specific problem? unfortunately i'm not able to repro off this info alone :(. are you able to open a simple [mono]repo that imitates your general setup/dir structure and repros this error? 🙏

@lindsaylevine lindsaylevine added type: bug code to address defects in shipped code priority: medium labels Mar 2, 2021
@laugharn
Copy link
Author

laugharn commented Mar 3, 2021

Hi @lindsaylevine, I've done a little bit more work and this appears to be a 10.0.8-canary issue, it builds correctly with 10.0.7

I'm doing the exploration at https://github.com/bungalohomes/exp building the main directory. I'm not sure how much access you have at Netlify but I can point you to some of our deployments/logs.

@lindsaylevine
Copy link

@laugharn

  1. ok good to know @ 10.0.8-canary
  2. i can see whatever you link me so send it over! :)

@lindsaylevine
Copy link

just checked, this is an issue for more than just monorepos. digging in now.

@segheysens
Copy link

Similar, I had to upgrade to Next 10.0.8-canary because of challenges with the sharp package on an M1 Macbook. Confirming that I'm seeing this error as well. Thanks for the quick work on that PR @lindsaylevine, lmk if there's any extra context I could share to help close this one out!

@lindsaylevine lindsaylevine changed the title Plugin Not Reading next.config.js Target 10.0.8 breaks plugin (can't read config target) Mar 7, 2021
@lindsaylevine
Copy link

@segheysens thanks stephen!! working on it!! requires a big refactor 😅

@brenelz
Copy link

brenelz commented Mar 8, 2021

I think I ran into a similar problem today with deploying next js 10.0.8. Nice work jumping on it so quickly!

@lindsaylevine
Copy link

fixed and released in v3.0.0!

@brenelz
Copy link

brenelz commented Mar 8, 2021

yay thats awesome I just tried it and it worked! I uninstalled and reinstalled the plugin to get the latest version not sure if required or not.

@lindsaylevine
Copy link

@brenelz if you had the plugin installed at a fixed version before, then you'd need to reinstall :) otherwise it should run on the latest!

@tgrassl
Copy link

tgrassl commented Mar 14, 2021

I still get the same message using next 10.0.7 and @netlify/plugin-nextjs@3.0.3 😕
Already reinstalled the plugin in the UI. The build last worked using @netlify/plugin-nextjs@2.0.1.

image

@segheysens
Copy link

segheysens commented Mar 14, 2021

@tgrassl have you tried updating next to 10.0.8? That's the topic of this issue and 10.0.8 with the 3.x upgrade on the Netlify plugin works for me

@tgrassl
Copy link

tgrassl commented Mar 14, 2021

@segheysens yes, but it's still the same

@segheysens
Copy link

@tgrassl could you attach your project or a sample project exhibiting this behavior for debugging?

@tgrassl
Copy link

tgrassl commented Mar 14, 2021

@segheysens Sure, here's a dummy project (https://github.com/tgrassl/nextjs-netlify-test) and the corresponding build log from Netlify. Did not configure anything else besides installing the Essential Next.js plugin from the UI

11:27:38 PM: Build ready to start
11:27:40 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
11:27:40 PM: build-image tag: v3.7.0
11:27:40 PM: buildbot version: c469f7ab4d394d961ca036b1163fdbb6ef9fb78c
11:27:40 PM: Building without cache
11:27:40 PM: Starting to prepare the repo for build
11:27:40 PM: No cached dependencies found. Cloning fresh repo
11:27:40 PM: git clone https://github.com/tgrassl/nextjs-netlify-test
11:27:42 PM: Preparing Git Reference refs/heads/main
11:27:43 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'out' versus 'out/' in the Netlify UI
11:27:43 PM: Starting build script
11:27:43 PM: Installing dependencies
11:27:43 PM: Python version set to 2.7
11:27:45 PM: v12.18.0 is already installed.
11:27:45 PM: Now using node v12.18.0 (npm v6.14.4)
11:27:45 PM: Started restoring cached build plugins
11:27:45 PM: Finished restoring cached build plugins
11:27:46 PM: Attempting ruby version 2.7.1, read from environment
11:27:47 PM: Using ruby version 2.7.1
11:27:48 PM: Using PHP version 5.6
11:27:48 PM: Started restoring cached node modules
11:27:48 PM: Finished restoring cached node modules
11:27:48 PM: Installing NPM modules using NPM version 6.14.4
11:27:56 PM: > core-js@3.9.1 postinstall /opt/build/repo/node_modules/core-js
11:27:56 PM: > node -e "try{require('./postinstall')}catch(e){}"
11:27:56 PM: npm WARN nextjs-netlify-test@1.0.0 No description
11:27:56 PM: npm WARN nextjs-netlify-test@1.0.0 No repository field.
11:27:56 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
11:27:56 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:27:56 PM: added 251 packages from 251 contributors and audited 253 packages in 7.411s
11:27:56 PM: 16 packages are looking for funding
11:27:56 PM:   run `npm fund` for details
11:27:56 PM: found 0 vulnerabilities
11:27:56 PM: NPM modules installed
11:27:57 PM: Started restoring cached go cache
11:27:57 PM: Finished restoring cached go cache
11:27:57 PM: go version go1.14.4 linux/amd64
11:27:57 PM: go version go1.14.4 linux/amd64
11:27:57 PM: Installing missing commands
11:27:57 PM: Verify run directory
11:27:59 PM: ​
11:27:59 PM: ────────────────────────────────────────────────────────────────
11:27:59 PM:   Netlify Build                                                 
11:27:59 PM: ────────────────────────────────────────────────────────────────
11:27:59 PM: ​
11:27:59 PM: ❯ Version
11:27:59 PM:   @netlify/build 9.9.5
11:27:59 PM: ​
11:27:59 PM: ❯ Flags
11:27:59 PM:   apiHost: api.netlify.com
11:27:59 PM:   cacheDir: /opt/build/cache
11:27:59 PM:   deployId: 604e8ddaa9112ef8d84f9f3e
11:27:59 PM:   mode: buildbot
11:27:59 PM:   testOpts:
11:27:59 PM:     silentLingeringProcesses: ''
11:27:59 PM: ​
11:27:59 PM: ❯ Current directory
11:27:59 PM:   /opt/build/repo
11:27:59 PM: ​
11:27:59 PM: ❯ Config file
11:27:59 PM:   No config file was defined: using default values.
11:27:59 PM: ​
11:27:59 PM: ❯ Context
11:27:59 PM:   production
11:27:59 PM: ​
11:27:59 PM: ❯ Installing plugins
11:27:59 PM:    - @netlify/plugin-nextjs@3.0.3
11:28:20 PM: ​
11:28:20 PM: ❯ Loading plugins
11:28:20 PM:    - @netlify/plugin-nextjs@3.0.3 from Netlify app
11:28:20 PM: ​
11:28:20 PM: ────────────────────────────────────────────────────────────────
11:28:20 PM:   1. onPreBuild command from @netlify/plugin-nextjs             
11:28:20 PM: ────────────────────────────────────────────────────────────────
11:28:20 PM: ​
11:28:21 PM: Your next.config.js must set the "target" property to one of: serverless, experimental-serverless-trace. Update the
11:28:21 PM:       target property to allow this plugin to run.
11:28:21 PM: ​
11:28:21 PM: (@netlify/plugin-nextjs onPreBuild completed in 828ms)
11:28:21 PM: ​
11:28:21 PM: ────────────────────────────────────────────────────────────────
11:28:21 PM:   2. Build command from Netlify app                             
11:28:21 PM: ────────────────────────────────────────────────────────────────
11:28:21 PM: ​
11:28:21 PM: $ npm run build
11:28:22 PM: > nextjs-netlify-test@1.0.0 build /opt/build/repo
11:28:22 PM: > next build
11:28:23 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
11:28:23 PM: info  - Creating an optimized production build...
11:28:43 PM: info  - Compiled successfully
11:28:43 PM: info  - Collecting page data...
11:28:44 PM: info  - Generating static pages (0/10)
11:28:46 PM: info  - Generating static pages (2/10)
11:28:46 PM: info  - Generating static pages (4/10)
11:28:46 PM: info  - Generating static pages (7/10)
11:28:46 PM: info  - Generating static pages (10/10)
11:28:46 PM: info  - Finalizing page optimization...
11:28:46 PM: Page                                                           Size     First Load JS
11:28:46 PM: ┌ ● /                                                          472 B            84 kB
11:28:46 PM: ├   /_app                                                      0 B            79.8 kB
11:28:46 PM: ├ ○ /404                                                       2.72 kB        82.5 kB
11:28:46 PM: └ ● /second-page                                               395 B          83.9 kB
11:28:46 PM: + First Load JS shared by all                                  79.8 kB
11:28:46 PM:   ├ chunks/08b56c1779dbdbb0e3e8dbde9a3df2a9ca8dae00.da1aa7.js  16 kB
11:28:46 PM:   ├ chunks/commons.5e5c3a.js                                   14.4 kB
11:28:46 PM:   ├ chunks/framework.9d5241.js                                 41.8 kB
11:28:46 PM:   ├ chunks/main.31e598.js                                      6.39 kB
11:28:46 PM:   ├ chunks/pages/_app.fb42d0.js                                496 B
11:28:46 PM:   └ chunks/webpack.50bee0.js                                   751 B
11:28:46 PM: λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
11:28:46 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
11:28:46 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
11:28:46 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
11:28:46 PM: ​
11:28:46 PM: (build.command completed in 25.1s)
11:28:46 PM: ​
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM:   3. onBuild command from @netlify/plugin-nextjs                
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM: ​
11:28:46 PM: Your next.config.js must set the "target" property to one of: serverless, experimental-serverless-trace. Update the
11:28:46 PM:       target property to allow this plugin to run.
11:28:46 PM: ​
11:28:46 PM: (@netlify/plugin-nextjs onBuild completed in 5ms)
11:28:46 PM: ​
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM:   4. Deploy site                                                
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM: ​
11:28:46 PM: ​
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM:   Configuration error                                           
11:28:46 PM: ────────────────────────────────────────────────────────────────
11:28:46 PM: ​
11:28:46 PM:   Error message
11:28:46 PM:   Deploy did not succeed: Deploy directory 'out' does not exist
11:28:46 PM: ​
11:28:46 PM:   Resolved config
11:28:46 PM:   build:
11:28:46 PM:     command: npm run build
11:28:46 PM:     commandOrigin: ui
11:28:46 PM:     publish: /opt/build/repo/out
11:28:46 PM:   plugins:
11:28:46 PM:     - inputs: {}
11:28:46 PM:       origin: ui
11:28:46 PM:       package: '@netlify/plugin-nextjs'
11:28:47 PM: Caching artifacts
11:28:47 PM: Started saving node modules
11:28:47 PM: Finished saving node modules
11:28:47 PM: Started saving build plugins
11:28:47 PM: Finished saving build plugins
11:28:47 PM: Started saving pip cache
11:28:47 PM: Finished saving pip cache
11:28:47 PM: Started saving emacs cask dependencies
11:28:47 PM: Finished saving emacs cask dependencies
11:28:47 PM: Started saving maven dependencies
11:28:47 PM: Finished saving maven dependencies
11:28:47 PM: Started saving boot dependencies
11:28:47 PM: Finished saving boot dependencies
11:28:47 PM: Started saving rust rustup cache
11:28:47 PM: Finished saving rust rustup cache
11:28:47 PM: Started saving go dependencies
11:28:47 PM: Finished saving go dependencies
11:28:49 PM: Build script success
11:29:07 PM: Finished processing build request in 1m26.655546342s

@lindsaylevine
Copy link

lindsaylevine commented Mar 15, 2021 via email

@tgrassl
Copy link

tgrassl commented Mar 15, 2021

Ahh okay, that makes sense. Thank you

@bcnichols3
Copy link

bcnichols3 commented Jul 13, 2021

I'm running Next 11 and @netlify/plugin-nextjs 3.6.3 and seeing this message when I deploy. The plugin's onPreBuild step is forcing next to build with target: serverless:

The "target" config property must be one of "serverless", "experimental-serverless-trace". Building with "serverless" target.

However the next.js team recommends you not use serverless. The results is a webpack 5 error that shows up with usage of next-auth — it tries to import all dynamic optional imports from TypeORM (which next-auth relies on) and is unable to find those dependencies and you'll get errors like this:

ModuleNotFoundError: Module not found: Error: Can't resolve 'mongodb' in '/opt/build/repo/node_modules/typeorm/platform'

The only way I've been able to build using Next11 is without serverless mode. Is there a way to tell this plugin not to turn on serverless mode?

@lindsaylevine
Copy link

@bcnichols3 hey! would you do me a huge favor and open a separate issue about this? don't think it belongs with 10.0.8 breakages. would appreciate it a bunch! we can discuss further there 🙏

@bcnichols3
Copy link

bcnichols3 commented Jul 13, 2021

done @lindsaylevine

#527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants