# Build error on API function with rebuild

**URL:** <https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403>\
**Category:** Support\
**Tags:** deployment\
**Created:** [April 4, 2021, 6:41pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403 "2021-04-04T18:41:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanoats](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ivanoats/32/23716_2.png) [@ivanoats](https://answers.netlify.com/u/ivanoats)\
**Post date:** [April 4, 2021, 6:41pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/1 "2021-04-04T18:41:32Z")

</div>

My site build seems to work locally but not on Netlify. Is the error at the end of the log below coming from the Netlify next plugin?

I’m not sure if this is a problem with my location of my `util` folder, or my config for functions in my Netlify.toml, or what. Any ideas?  
The full site code is at: [GitHub - ivanoats/nextweather: Weather station data focused on wind and tide for human powered watercraft](https://github.com/ivanoats/nextweather/)

[https://nextweather.netlify.app/](https://nextweather.netlify.app/)

11:32:57 AM: Build ready to start  
11:32:58 AM: build-image version: be42e453d6c8f171cc2f654acc29c0a8b60e6d93  
11:32:58 AM: build-image tag: v3.7.1  
11:32:58 AM: buildbot version: 7bdd3b07036ec50a4d44b86fbdc90f52d3e07727  
11:32:58 AM: Fetching cached dependencies  
11:32:59 AM: Starting to download cache of 1.0GB  
11:33:06 AM: Finished downloading cache in 7.233829913s  
11:33:06 AM: Starting to extract cache  
11:33:47 AM: Finished extracting cache in 41.361791255s  
11:33:48 AM: Finished fetching cache in 49.100605268s  
11:33:48 AM: Starting to prepare the repo for build  
11:33:48 AM: Preparing Git Reference refs/heads/main  
11:33:50 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘Users/ivan/dev/nextweather/out\_publish’ versus ‘/Users/ivan/dev/nextweather/out\_publish’ in the Netlify UI  
11:33:50 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: ‘pages/api’ versus ‘’ in the Netlify UI  
11:33:51 AM: Starting build script  
11:33:51 AM: Installing dependencies  
11:33:51 AM: Python version set to 2.7  
11:33:51 AM: Started restoring cached node version  
11:33:54 AM: Finished restoring cached node version  
11:33:55 AM: v12.18.0 is already installed.  
11:33:56 AM: Now using node v12.18.0 (npm v6.14.4)  
11:33:56 AM: Started restoring cached build plugins  
11:33:56 AM: Finished restoring cached build plugins  
11:33:56 AM: Attempting ruby version 2.7.1, read from environment  
11:33:58 AM: Using ruby version 2.7.1  
11:33:58 AM: Using PHP version 5.6  
11:33:58 AM: Started restoring cached node modules  
11:33:58 AM: Finished restoring cached node modules  
11:33:58 AM: Installing NPM modules using NPM version 6.14.4  
11:34:08 AM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!npm WARN acorn-export-ns-from@0.1.0 requires a peer of acorn@^6.0.1 but none is installed. You must install peer dependencies yourself.  
11:34:08 AM: npm WARN react-native-get-random-values@1.6.0 requires a peer of react-native@\>=0.56 but none is installed. You must install peer dependencies yourself.  
11:34:08 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node\_modules/fsevents):  
11:34:08 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})  
11:34:08 AM: added 5 packages from 30 contributors and audited 1038 packages in 9.022s  
11:34:09 AM: 68 packages are looking for funding  
11:34:09 AM: run `npm fund` for details  
11:34:09 AM: found 0 vulnerabilities  
11:34:09 AM: NPM modules installed  
11:34:09 AM: Started restoring cached go cache  
11:34:09 AM: Finished restoring cached go cache  
11:34:09 AM: go version go1.14.4 linux/amd64  
11:34:09 AM: go version go1.14.4 linux/amd64  
11:34:09 AM: Installing missing commands  
11:34:09 AM: Verify run directory  
11:34:11 AM: ​  
11:34:11 AM: ────────────────────────────────────────────────────────────────  
11:34:11 AM: Netlify Build  
11:34:11 AM: ────────────────────────────────────────────────────────────────  
11:34:11 AM: ​  
11:34:11 AM: ❯ Version  
11:34:11 AM: @netlify/build 10.2.2  
11:34:11 AM: ​  
11:34:11 AM: ❯ Flags  
11:34:11 AM: deployId: 606a06581e1955000748f9c2  
11:34:11 AM: ​  
11:34:11 AM: ❯ Current directory  
11:34:11 AM: /opt/build/repo  
11:34:11 AM: ​  
11:34:11 AM: ❯ Config file  
11:34:11 AM: /opt/build/repo/netlify.toml  
11:34:11 AM: ​  
11:34:11 AM: ❯ Context  
11:34:11 AM: production  
11:34:11 AM: ​  
11:34:11 AM: ❯ Loading plugins  
11:34:11 AM: - @netlify/plugin-nextjs@3.0.3 from netlify.toml and package.json  
11:34:11 AM: ​  
11:34:11 AM: ────────────────────────────────────────────────────────────────  
11:34:11 AM: 1. onPreBuild command from @netlify/plugin-nextjs  
11:34:11 AM: ────────────────────────────────────────────────────────────────  
11:34:11 AM: ​  
11:34:12 AM: info - Using webpack 5. Reason: future.webpack5 option enabled [webpack5 | Next.js](https://nextjs.org/docs/messages/webpack5)  
11:34:12 AM: ​  
11:34:12 AM: (@netlify/plugin-nextjs onPreBuild completed in 988ms)  
11:34:12 AM: ​  
11:34:12 AM: ────────────────────────────────────────────────────────────────  
11:34:12 AM: 2. build.command from netlify.toml  
11:34:12 AM: ────────────────────────────────────────────────────────────────  
11:34:12 AM: ​  
11:34:12 AM: $ npm run build  
11:34:13 AM: \> nextweather@0.1.0 build /opt/build/repo  
11:34:13 AM: \> next build  
11:34:14 AM: info - Using webpack 5. Reason: future.webpack5 option enabled [webpack5 | Next.js](https://nextjs.org/docs/messages/webpack5)  
11:34:15 AM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: [no-cache | Next.js](https://nextjs.org/docs/messages/no-cache)  
11:34:15 AM: info - Checking validity of types…  
11:34:18 AM: info - Creating an optimized production build…  
11:34:32 AM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can’t resolve ‘fsevents’ in ‘/opt/build/repo/node\_modules/chokidar’ while resolving ‘fsevents’ in /opt/build/repo/node\_modules/chokidar to a directory  
11:34:35 AM: (node:1394) [DEP\_WEBPACK\_CHUNK\_HAS\_ENTRY\_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API  
11:34:36 AM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can’t resolve ‘fsevents’ in ‘/opt/build/repo/node\_modules/chokidar’ while resolving ‘fsevents’ in /opt/build/repo/node\_modules/chokidar to a directory  
11:34:36 AM: warn - Compiled with warnings  
11:34:36 AM: ./node\_modules/keyv/src/index.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: ./node\_modules/next/dist/next-server/server/load-components.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: ./node\_modules/next/dist/next-server/server/load-components.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: ./node\_modules/next/dist/next-server/server/require.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: ./node\_modules/next/dist/next-server/server/require.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: ./node\_modules/next/dist/next-server/server/require.js  
11:34:36 AM: Critical dependency: the request of a dependency is an expression  
11:34:36 AM: info - Collecting page data…  
11:34:37 AM: info - Generating static pages (0/3)  
11:34:38 AM: info - Generating static pages (3/3)  
11:34:38 AM: info - Finalizing page optimization…  
11:34:38 AM: Page Size First Load JS  
11:34:38 AM: ┌ ○ / 3.44 kB 67.5 kB  
11:34:38 AM: ├ └ css/9a0e57cc520cbbcc7d30.css 669 B  
11:34:38 AM: ├ /\_app 0 B 64.1 kB  
11:34:38 AM: ├ ○ /404 3.44 kB 67.5 kB  
11:34:38 AM: ├ λ /api/csv 0 B 64.1 kB  
11:34:38 AM: ├ λ /api/observations 0 B 64.1 kB  
11:34:38 AM: ├ λ /api/tsv 0 B 64.1 kB  
11:34:38 AM: └ λ /api/util/convert 0 B 64.1 kB  
11:34:38 AM: + First Load JS shared by all 64.1 kB  
11:34:38 AM: ├ chunks/597.b0deca.js 13.3 kB  
11:34:38 AM: ├ chunks/778.7db2cf.js 7.05 kB  
11:34:38 AM: ├ chunks/framework.dad012.js 42 kB  
11:34:38 AM: ├ chunks/main.9ca82e.js 151 B  
11:34:38 AM: ├ chunks/pages/\_app.65838e.js 564 B  
11:34:38 AM: ├ chunks/webpack.37bb74.js 993 B  
11:34:38 AM: └ css/9555fbe4118c83c59ab9.css 203 B  
11:34:38 AM: λ (Lambda) server-side renders at runtime (uses getInitialProps or getServerSideProps)  
11:34:38 AM: ○ (Static) automatically rendered as static HTML (uses no initial props)  
11:34:38 AM: ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)  
11:34:38 AM: (ISR) incremental static regeneration (uses revalidate in getStaticProps)  
11:34:38 AM: ​  
11:34:38 AM: (build.command completed in 25.6s)  
11:34:38 AM: ​  
11:34:38 AM: ────────────────────────────────────────────────────────────────  
11:34:38 AM: 3. onBuild command from @netlify/plugin-nextjs  
11:34:38 AM: ────────────────────────────────────────────────────────────────  
11:34:38 AM: ​  
11:34:38 AM: \*\* Running Next on Netlify package \*\*  
11:34:38 AM: 🚀 Next on Netlify 🚀  
11:34:38 AM: 🌍 Copying public/ folder to Users/ivan/dev/nextweather/out\_publish  
11:34:39 AM: info - Using webpack 5. Reason: future.webpack5 option enabled [webpack5 | Next.js](https://nextjs.org/docs/messages/webpack5)  
11:34:39 AM: 💼 Copying static NextJS assets to Users/ivan/dev/nextweather/out\_publish  
11:34:39 AM: 💫 Setting up API endpoints as Netlify Functions in pages/api  
11:34:39 AM: 💫 Setting up pages with getInitialProps as Netlify Functions in pages/api  
11:34:39 AM: 💫 Setting up pages with getServerSideProps as Netlify Functions in pages/api  
11:34:39 AM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to Users/ivan/dev/nextweather/out\_publish  
11:34:39 AM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in pages/api  
11:34:39 AM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in pages/api  
11:34:39 AM: 🔥 Copying pre-rendered pages without props to Users/ivan/dev/nextweather/out\_publish  
11:34:39 AM: 🔀 Setting up redirects  
11:34:39 AM: 🔀 Setting up headers  
11:34:39 AM: ✅ Success! All done!  
11:34:39 AM: ​  
11:34:39 AM: (@netlify/plugin-nextjs onBuild completed in 757ms)  
11:34:39 AM: ​  
11:34:39 AM: ────────────────────────────────────────────────────────────────  
11:34:39 AM: 4. Functions bundling  
11:34:39 AM: ────────────────────────────────────────────────────────────────  
11:34:39 AM: ​  
11:34:39 AM: Packaging Functions from pages/api directory:  
11:34:39 AM: - csv.ts  
11:34:39 AM: - next\_image.js  
11:34:39 AM: - observations.js  
11:34:39 AM: - tsv.js  
11:34:39 AM: - next\_api\_csv/next\_api\_csv.js  
11:34:39 AM: - next\_api\_observations/next\_api\_observations.js  
11:34:39 AM: - next\_api\_tsv/next\_api\_tsv.js  
11:34:39 AM: - next\_api\_util\_convert/next\_api\_util\_convert.js  
11:34:39 AM: ​  
11:34:39 AM: \> node\_modules/got/dist/source/core/utils/get-buffer.js:7:8: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 7 │ for await (const chunk of stream) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:157:26: error: Transforming async generator functions to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 157 │ const paginateEach = (async function\* (url, options) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:213:12: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 213 │ for await (const item of paginateEach(url, options)) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> pages/api/csv.ts:3:36: error: Could not resolve “./util/convert”  
11:34:39 AM: 3 │ import { metersPerSecondToMph} from ‘./util/convert’;  
11:34:39 AM: ╵ ~~~~~~~~~~~~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/core/utils/get-buffer.js:7:8: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 7 │ for await (const chunk of stream) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:157:26: error: Transforming async generator functions to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 157 │ const paginateEach = (async function\* (url, options) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:213:12: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 213 │ for await (const item of paginateEach(url, options)) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:157:26: error: Transforming async generator functions to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 157 │ const paginateEach = (async function\* (url, options) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/create.js:213:12: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 213 │ for await (const item of paginateEach(url, options)) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/keyv/src/index.js:18:14: warning: This call to “require” will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)  
11:34:39 AM: 18 │ return new (require(adapters[adapter]))(opts);  
11:34:39 AM: ╵ ~~~~~~~  
11:34:39 AM: \> node\_modules/got/dist/source/core/utils/get-buffer.js:7:8: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 7 │ for await (const chunk of stream) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> node\_modules/keyv/src/index.js:18:14: warning: This call to “require” will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)  
11:34:39 AM: 18 │ return new (require(adapters[adapter]))(opts);  
11:34:39 AM: ╵ ~~~~~~~  
11:34:39 AM: \> node\_modules/keyv/src/index.js:18:14: warning: This call to “require” will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)  
11:34:39 AM: 18 │ return new (require(adapters[adapter]))(opts);  
11:34:39 AM: ╵ ~~~~~~~  
11:34:39 AM: \> pages/api/next\_api\_csv/nextPage/index.js:12072:8: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 12072 │ for await (const chunk of stream) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> pages/api/next\_api\_csv/nextPage/index.js:12588:26: error: Transforming async generator functions to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 12588 │ const paginateEach = (async function\* (url, options) {  
11:34:39 AM: ╵ ~~~~~  
11:34:39 AM: \> pages/api/next\_api\_csv/nextPage/index.js:12644:12: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:39 AM: 12644 │ for await (const item of paginateEach(url, options)) {  
11:34:39 AM: ╵ ~~~~~  
11:34:42 AM: ​  
11:34:42 AM: ────────────────────────────────────────────────────────────────  
11:34:42 AM: Dependencies installation error  
11:34:42 AM: ────────────────────────────────────────────────────────────────  
11:34:42 AM: ​  
11:34:42 AM: Error message  
11:34:42 AM: A Netlify Function failed to require one of its dependencies.  
11:34:42 AM: Please make sure it is present in the site’s top-level “package.json”.​  
11:34:42 AM: Build failed with 4 errors:  
11:34:42 AM: node\_modules/got/dist/source/core/utils/get-buffer.js:7:8: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:42 AM: node\_modules/got/dist/source/create.js:157:26: error: Transforming async generator functions to the configured target environment (“es2017”) is not supported yet  
11:34:42 AM: node\_modules/got/dist/source/create.js:213:12: error: Transforming for-await loops to the configured target environment (“es2017”) is not supported yet  
11:34:42 AM: pages/api/csv.ts:3:36: error: Could not resolve “./util/convert”  
11:34:42 AM: ​  
11:34:42 AM: Resolved config  
11:34:42 AM: build:  
11:34:42 AM: command: npm run build  
11:34:42 AM: commandOrigin: config  
11:34:42 AM: publish: /opt/build/repo/Users/ivan/dev/nextweather/out\_publish  
11:34:42 AM: functions:  
11:34:42 AM: ‘\*’:  
11:34:42 AM: node\_bundler: esbuild  
11:34:42 AM: functionsDirectory: /opt/build/repo/pages/api  
11:34:42 AM: plugins:  
11:34:42 AM: - inputs: {}  
11:34:42 AM: origin: config  
11:34:42 AM: package: ‘@netlify/plugin-nextjs’  
11:34:43 AM: Caching artifacts  
11:34:43 AM: Started saving node modules  
11:34:43 AM: Finished saving node modules  
11:34:43 AM: Started saving build plugins  
11:34:43 AM: Finished saving build plugins  
11:34:43 AM: Started saving pip cache  
11:34:43 AM: Finished saving pip cache  
11:34:43 AM: Started saving emacs cask dependencies  
11:34:43 AM: Finished saving emacs cask dependencies  
11:34:43 AM: Started saving maven dependencies  
11:34:43 AM: Finished saving maven dependencies  
11:34:43 AM: Started saving boot dependencies  
11:34:43 AM: Finished saving boot dependencies  
11:34:43 AM: Started saving rust rustup cache  
11:34:43 AM: Finished saving rust rustup cache  
11:34:43 AM: Started saving go dependencies  
11:34:43 AM: Finished saving go dependencies  
11:34:43 AM: Build failed due to a user error: Build script returned non-zero exit code: 2  
11:34:43 AM: Failing build: Failed to build site  
11:34:43 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2  
11:34:43 AM: Finished processing build request in 1m44.842282737s

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 14, 2021, 1:34pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/2 "2021-04-14T13:34:20Z")

</div>

Hey there, @ivanoats

Sorry for the slow response. I see that this thread has been quiet since you first shared your question. Are you still encountering this issue? If so, what additional steps have you taken to debug since you first posted this? Have you seen our [Next.js documentation](https://answers.netlify.com/t/essential-next-js-build-plugin-now-with-auto-installation/34380)?

Let us know! 🙂

---

<div class="post-metadata">

**Author:** ![ivanoats](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ivanoats/32/23716_2.png) [@ivanoats](https://answers.netlify.com/u/ivanoats)\
**Post date:** [April 15, 2021, 1:29am UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/3 "2021-04-15T01:29:03Z")

</div>

No worries.

1. I did get a great response from tech support
2. I have been camping and just in town to get gas so haven’t tried it yet. I will let you know next week 🕶

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 15, 2021, 1:37pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/4 "2021-04-15T13:37:22Z")

</div>

Sounds good, @ivanoats ! I will leave this thread open. Have a great time camping!

---

<div class="post-metadata">

**Author:** ![ivanoats](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ivanoats/32/23716_2.png) [@ivanoats](https://answers.netlify.com/u/ivanoats)\
**Post date:** [April 21, 2021, 2:29pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/5 "2021-04-21T14:29:47Z")

</div>

Ok, I did get the build to work, or succeed, but there is nothing getting output and all pages are 404-ing. It works fine on V… what am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 21, 2021, 2:34pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/6 "2021-04-21T14:34:48Z")

</div>

Glad you got the build working!

We have a few threads related to this issue, but two that I recommend starting with are this [Support Guide](https://answers.netlify.com/t/support-guide-i-ve-deployed-my-site-but-i-still-see-page-not-found/125) and this [page not found while using Nextjs](https://answers.netlify.com/t/page-not-found-when-deploying-nextjs/19442). I recommend starting with the Support Guide first!

Once you follow those steps, let us know if it is working!

---

<div class="post-metadata">

**Author:** ![ivanoats](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ivanoats/32/23716_2.png) [@ivanoats](https://answers.netlify.com/u/ivanoats)\
**Post date:** [April 21, 2021, 3:56pm UTC](https://answers.netlify.com/t/build-error-on-api-function-with-rebuild/35403/7 "2021-04-21T15:56:39Z")

</div>

yes, I had followed all those before posting.

The only thing that ended up working was removing all deploy settings. Then the Netlify UI asked to install the NextJS plugin, and then re-adding `npm run build` finally fixed things.
