I started having the same problem today on a Nextjs 14 project.
16:47:06.130 ✘ [ERROR] Could not resolve "async_hooks"
16:47:06.130
16:47:06.130 <stdin>:364:680:
16:47:06.130 364 │ ...:()=>N});var R=A(require("async_hooks")),S="@next/request-cont...
16:47:06.131 ╵ ~~~~~~~~~~~~~
16:47:06.131
16:47:06.131 The package "async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
16:47:06.131
16:47:06.494 /opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1575
16:47:06.494 let error = new Error(`${text}${summary}`);
16:47:06.494 ^
16:47:06.495
16:47:06.495 Error: Build failed with 1 error:
16:47:06.495 <stdin>:364:680: ERROR: Could not resolve "async_hooks"
16:47:06.495 at failureErrorWithLog (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1575:15)
16:47:06.496 at /opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1033:28
16:47:06.496 at runOnEndCallbacks (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1447:61)
16:47:06.496 at buildResponseToResult (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1031:7)
16:47:06.497 at /opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:1143:14
16:47:06.497 at responseCallbacks.<computed> (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:680:9)
16:47:06.497 at handleIncomingPacket (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:735:9)
16:47:06.497 at Socket.readFromStdout (/opt/buildhome/.npm/_npx/ae7d8149b8ab8d52/node_modules/esbuild/lib/main.js:656:7)
16:47:06.497 at Socket.emit (node:events:514:28)
16:47:06.498 at addChunk (node:internal/streams/readable:324:12) {
16:47:06.498 errors: [
16:47:06.498 {
16:47:06.498 detail: undefined,
16:47:06.499 id: '',
16:47:06.499 location: {
16:47:06.499 column: 680,
16:47:06.499 file: '<stdin>',
16:47:06.499 length: 13,
16:47:06.500 line: 364,
16:47:06.500 lineText: ' const fn = (function(module,exports) {var b=Object.create;var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var h=e=>p(e,"__esModule",{value:!0});var _=(e,n)=>{h(e);for(var t in n)p(e,t,{get:n[t],enumerable:!0})},U=(e,n,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of T(n))!L.call(e,i)&&i!=="default"&&p(e,i,{get:()=>n[i],enumerable:!(t=w(n,i))||t.enumerable});return e},A=e=>U(h(p(e!=null?b(P(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);_(exports,{default:()=>N});var R=A(require("async_hooks")),S="@next/request-context",f=Symbol.for(S),C=Symbol.for("internal.storage");function O(){let e=globalThis;if(!e[f]){let n=new R.AsyncLocalStorage,t={get:()=>n.getStore(),[C]:n};e[f]=t}return e[f]}var q=O();function m(e,n){return q[C].run(e,n)}function y(e){let n={};return e&&e.forEach((t,i)=>{n[i]=t,i.toLowerCase()==="set-cookie"&&(n[i]=M(t))}),n}function M(e){let n=[],t=0,i,a,g,o,r;function x(){for(;t<e.length&&/\\s/.test(e.charAt(t));)t+=1;return t<e.length}function s(){return a=e.charAt(t),a!=="="&&a!==";"&&a!==","}for(;t<e.length;){for(i=t,r=!1;x();)if(a=e.charAt(t),a===","){for(g=t,t+=1,x(),o=t;t<e.length&&s();)t+=1;t<e.length&&e.charAt(t)==="="?(r=!0,t=o,n.push(e.substring(i,g)),i=t):t=g+1}else t+=1;(!r||t>=e.length)&&n.push(e.substring(i,e.length))}return n}function N(e){let n=e.staticRoutes.map(i=>({regexp:new RegExp(i.namedRegex),page:i.page})),t=e.dynamicRoutes?.map(i=>({regexp:new RegExp(i.namedRegex),page:i.page}))||[];return async function(a,g){let o=new URL(a.url).pathname,r={};if(e.nextConfig?.basePath&&o.startsWith(e.nextConfig.basePath)&&(o=o.replace(e.nextConfig.basePath,"")||"/"),e.nextConfig?.i18n)for(let s of e.nextConfig.i18n.locales){let u=new RegExp(`^/${s}($|/)`,"i");if(o.match(u)){o=o.replace(u,"/")||"/";break}}for(let s of n)if(s.regexp.exec(o)){r.name=s.page;break}if(!r.name){let s=E(o);for(let u of t||[]){if(s&&!E(u.page))continue;let d=u.regexp.exec(o);if(d){r={name:u.page,params:d.groups};break}}}let x=await m({waitUntil:g.waitUntil},()=>globalThis._ENTRIES[`middleware_${e.name}`].default.call({},{request:{url:a.url,method:a.method,headers:y(a.headers),ip:c(a.headers,l.Ip),geo:{city:c(a.headers,l.City,!0),country:c(a.headers,l.Country,!0),latitude:c(a.headers,l.Latitude),longitude:c(a.headers,l.Longitude),region:c(a.headers,l.Region,!0)},nextConfig:e.nextConfig,page:r,body:a.body}}));return x.waitUntil&&g.waitUntil(x.waitUntil),x.response}}function c(e,n,t=!1){let i=e.get(n)||void 0;return t&&i?decodeURIComponent(i):i}function E(e){return e==="/api"||e.startsWith("/api/")}var l;(function(o){o.City="x-vercel-ip-city",o.Country="x-vercel-ip-country",o.Ip="x-real-ip",o.Latitude="x-vercel-ip-latitude",o.Longitude="x-vercel-ip-longitude",o.Region="x-vercel-ip-country-region"})(l||(l={}));',
16:47:06.500 namespace: '',
16:47:06.500 suggestion: ''
16:47:06.500 },
16:47:06.500 notes: [
16:47:06.500 {
16:47:06.500 location: null,
16:47:06.501 text: `The package "async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.`
16:47:06.501 }
16:47:06.501 ],
16:47:06.501 pluginName: '',
16:47:06.501 text: 'Could not resolve "async_hooks"'
16:47:06.501 }
16:47:06.501 ],
16:47:06.501 warnings: [
16:47:06.501 {
16:47:06.501 detail: undefined,
16:47:06.502 id: 'direct-eval',
16:47:06.502 location: {
16:47:06.502 column: 256083,
16:47:06.502 file: '<stdin>',
16:47:06.502 length: 4,
16:47:06.502 line: 356,
16:47:06.502 lineText: '/**/;(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1695],{58399:__chunk_58399,49523:__chunk_49523,38846:function(module,exports,__webpack_require__){"undefined"!=typeof navigator&&function(e,t){module.exports=t()}(0,function(){"use strict";var svgNS="http://www.w3.org/2000/svg",locationHref="",_useWebWorker=!1,initialDefaultFrame=-999999,setWebWorker=function(e){_useWebWorker=!!e},getWebWorker=function(){return _useWebWorker},setLocationHref=function(e){locationHref=e},getLocationHref=function(){return locationHref};function createTag(e){return document.createElement(e)}function extendPrototype(e,t){var r,n,i=e.length;for(r=0;r<i;r+=1)for(var s in n=e[r].prototype)Object.prototype.hasOwnProperty.call(n,s)&&(t.prototype[s]=n[s])}function getDescriptor(e,t){return Object.getOwnPropertyDescriptor(e,t)}function createProxyFunction(e){function t(){}return t.prototype=e,t}var audioControllerFactory=function(){function e(e){this.audios=[],this.audioFactory=e,this._volume=1,this._isMuted=!1}return e.prototype={addAudio:function(e){this.audios.push(e)},pause:function(){var e,t=this.audios.length;for(e=0;e<t;e+=1)this.audios[e].pause()},resume:function(){var e,t=this.audios.length;for(e=0;e<t;e+=1)this.audios[e].resume()},setRate:function(e){var t,r=this.audios.length;for(t=0;t<r;t+=1)this.audios[t].setRate(e)},createAudio:function(e){return this.audioFactory?this.audioFactory(e):window.Howl?new window.Howl({src:[e]}):{isPlaying:!1,play:function(){this.isPlaying=!0},seek:function(){this.isPlaying=!1},playing:function(){},rate:function(){},setVolume:function(){}}},setAudioFactory:function(e){this.audioFactory=e},setVolume:function(e){this._volume=e,this._updateVolume()},mute:function(){this._isMuted=!0,this._updateVolume()},unmute:function(){this._isMuted=!1,this._updateVolume()},getVolume:function(){return this._volume},_updateVolume:function(){var e,t=this.audios.length;for(e=0;e<t;e+=1)this.audios[e].volume(this._volume*(this._isMuted?0:1))}},function(){return new e}}(),createTypedArray=function(){function e(e,t){var r,n=0,i=[];switch(e){case"int16":case"uint8c":r=1;break;default:r=1.1}for(n=0;n<t;n+=1)i.push(r);return i}function t(t,r){return"float32"===t?new Float32Array(r):"int16"===t?new Int16Array(r):"uint8c"===t?new Uint8ClampedArray(r):e(t,r)}return"function"==typeof Uint8ClampedArray&&"function"==typeof Float32Array?t:e}();function createSizedArray(e){return Array.apply(null,{length:e})}function _typeof$6(e){return(_typeof$6="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var subframeEnabled=!0,expressionsPlugin=null,expressionsInterfaces=null,idPrefix$1="",isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),_shouldRoundValues=!1,bmPow=Math.pow,bmSqrt=Math.sqrt,bmFloor=Math.floor,bmMax=Math.max,bmMin=Math.min,BMMath={};function ProjectInterface$1(){return{}}!function(){var e,t=["abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","cbrt","expm1","clz32","cos","cosh","exp","floor","fround","hypot","imul","log","log1p","log2","log10","max","min","pow","random","round","sign","sin","sinh","sqrt","tan","tanh","trunc","E","LN10","LN2","LOG10E","LOG2E","PI","SQRT1_2","SQRT2"],r=t.length;for(e=0;e<r;e+=1)BMMath[t[e]]=Math[t[e]]}(),BMMath.random=Math.random,BMMath.abs=function(e){if("object"===_typeof$6(e)&&e.length){var t,r=createSizedArray(e.length),n=e.length;for(t=0;t<n;t+=1)r[t]=Math.abs(e[t]);return r}return Math.abs(e)};var defaultCurveSegments=150,degToRads=Math.PI/180,roundCorner=.5519;function roundValues(e){_shouldRoundValues=!!e}function bmRnd(e){return _shouldRoundValues?Math.round(e):e}function styleDiv(e){e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.display="block",e.style.transformOrigin="0 0",e.style.webkitTransformOrigin="0 0",e.style.backfaceVisibility="visible",e.style.webkitBackfaceVisibility="visible",e.style.transformStyle="preserve-3d",e.style.webkitTransformStyle="preserve-3d",e.style.mozTransformStyle="preserve-3d"}function BMEnterFrameEvent(e,t,r,n){this.type=e,this.currentTime=t,this.totalTime=r,this.direction=n<0?-1:1}function BMCompleteEvent(e,t){this.type=e,this.direction=t<0?-1:1}function BMCompleteLoopEvent(e,t,r,n){this.type=e,this.currentLoop=r,this.totalLoops=t,this.direction=n<0?-1:1}function BMSegmentStartEvent(e,t,r){this.type=e,this.firstFrame=t,this.totalFrames=r}function BMDestroyEvent(e,t){this.type=e,this.target=t}function BMRenderFrameErrorEvent(e,t){this.type="renderFrameError",this.nativeError=e,this.currentTime=t}function BMConfigErrorEvent(e){this.type="configError",this.nativeError=e}function BMAnimationConfigErrorEvent(e,t){this.type=e,this.nativeError=t}var createElementID=function(){var e=0;return function(){return e+=1,idPrefix$1+"__lottie_element_"+e}}();function HSVtoRGB(e,t,r){var n,i,s,a,o,l,u,c;switch(a=Math.floor(6*e),o=6*e-a,l=r*(1-t),u=r*(1-o*t),c=r*(1-(1-o)*t),a%6){case 0:n=r,i=c,s=l;break;case 1:n=u,i=r,s=l;break;case 2:n=l,i=r,s=c;break;case 3:n=l,i=u,s=r;break;case 4:n=c,i=l,s=r;break;case 5:n=r,i=l,s=u}return[n,i,s]}function RGBtoHSV(e,t,r){var n,i=Math.max(e,t,r),s=Math.min(e,t,r),a=i-s,o=0===i?0:a/i,l=i/255;switch(i){case s:n=0;break;case e:n=(t-r+a*(t<r?6:0))/(6*a);break;case t:n=(r-e+2*a)/(6*a);break;case r:n=(e-t+4*a)/(6*a)}return[n,o,l]}function addSaturationToRGB(e,t){var r=RGBtoHSV(255*e[0],255*e[1],255*e[2]);return r[1]+=t,r[1]>1?r[1]=1:r[1]<=0&&(r[1]=0),HSVtoRGB(r[0],r[1],r[2])}function addBrightnessToRGB(e,t){var r=RGBtoHSV(255*e[0],255*e[1],255*e[2]);return r[2]+=t,r[2]>1?r[2]=1:r[2]<0&&(r[2]=0),HSVtoRGB(r[0],r[1],r[2])}function addHueToRGB(e,t){var r=RGBtoHSV(255*e[0],255*e[1],255*e[2]);return r[0]+=t/360,r[0]>1?r[0]-=1:r[0]<0&&(r[0]+=1),HSVtoRGB(r[0],r[1],r[2])}var rgbToHex=function(){var e,t,r=[];for(e=0;e<256;e+=1)t=e.toString(16),r[e]=1===t.length?"0"+t:t;return function(e,t,n){return e<0&&(e=0),t<0&&(t=0),n<0&&(n=0),"#"+r[e]+r[t]+r[n]}}(),setSubframeEnabled=function(e){subframeEnabled=!!e},getSubframeEnabled=function(){return subframeEnabled},setExpressionsPlugin=function(e){expressionsPlugin=e},getExpressionsPlugin=function(){return expressionsPlugin},setExpressionInterfaces=function(e){expressionsInterfaces=e},getExpressionInterfaces=function(){return expressionsInterfaces},setDefaultCurveSegments=function(e){defaultCurveSegments=e},getDefaultCurveSegments=function(){return defaultCurveSegments},setIdPrefix=function(e){idPrefix$1=e},getIdPrefix=function(){return idPrefix$1};function createNS(e){return document.createElementNS(svgNS,e)}function _typeof$5(e){return(_typeof$5="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var dataManager=function(){var e,t,r=1,n=[],i={onmessage:function(){},postMessage:function(t){e({data:t})}},s={postMessage:function(e){i.onmessage({data:e})}};function a(t){if(window.Worker&&window.Blob&&getWebWorker()){var r=new Blob(["var _workerSelf = self; self.onmessage = ",t.toString()],{type:"text/javascript"});return new Worker(URL.createObjectURL(r))}return e=t,i}function o(){t||((t=a(function(e){function t(){function e(t,r){var a,o,l,u,c,h,d=t.length;for(o=0;o<d;o+=1)if("ks"in(a=t[o])&&!a.completed){if(a.completed=!0,a.hasMask){var f=a.masksProperties;for(l=0,u=f.length;l<u;l+=1)if(f[l].pt.k.i)s(f[l].pt.k);else for(c=0,h=f[l].pt.k.length;c<h;c+=1)f[l].pt.k[c].s&&s(f[l].pt.k[c].s[0]),f[l].pt.k[c].e&&s(f[l].pt.k[c].e[0])}0===a.ty?(a.layers=n(a.refId,r),e(a.layers,r)):4===a.ty?i(a.shapes):5===a.ty&&p(a)}}function t(t,r){if(t){var i=0,s=t.length;for(i=0;i<s;i+=1)1===t[i].t&&(t[i].data.layers=n(t[i].data.refId,r),e(t[i].data.layers,r))}}function r(e,t){for(var r=0,n=t.length;r<n;){if(t[r].id===e)return t[r];r+=1}return null}function n(e,t){var n=r(e,t);return n?n.layers.__used?JSON.parse(JSON.stringify(n.layers)):(n.layers.__used=!0,n.layers):null}function i(e){var t,r,n;for(t=e.length-1;t>=0;t-=1)if("sh"===e[t].ty){if(e[t].ks.k.i)s(e[t].ks.k);else for(r=0,n=e[t].ks.k.length;r<n;r+=1)e[t].ks.k[r].s&&s(e[t].ks.k[r].s[0]),e[t].ks.k[r].e&&s(e[t].ks.k[r].e[0])}else"gr"===e[t].ty&&i(e[t].it)}function s(e){var t,r=e.i.length;for(t=0;t<r;t+=1)e.i[t][0]+=e.v[t][0],e.i[t][1]+=e.v[t][1],e.o[t][0]+=e.v[t][0],e.o[t][1]+=e.v[t][1]}function a(e,t){var r=t?t.split("."):[100,100,100];return e[0]>r[0]||!(r[0]>e[0])&&(e[1]>r[1]||!(r[1]>e[1])&&(e[2]>r[2]||!(r[2]>e[2])&&null))}var o=function(){var e=[4,4,14];function t(e){var t=e.t.d;e.t.d={k:[{s:t,t:0}]}}function r(e){var r,n=e.length;for(r=0;r<n;r+=1)5===e[r].ty&&t(e[r])}return function(t){if(a(e,t.v)&&(r(t.layers),t.assets)){var n,i=t.assets.length;for(n=0;n<i;n+=1)t.assets[n].layers&&r(t.assets[n].layers)}}}(),l=function(){var e=[4,7,99];return function(t){if(t.chars&&!a(e,t.v)){var r,n=t.chars.length;for(r=0;r<n;r+=1){var s=t.chars[r];s.data&&s.data.shapes&&(i(s.data.shapes),s.data.ip=0,s.data.op=99999,s.data.st=0,s.data.sr=1,s.data.ks={p:{k:[0,0],a:0},s:{k:[100,100],a:0},a:{k:[0,0],a:0},r:{k:0,a:0},o:{k:100,a:0}},t.chars[r].t||(s.data.shapes.push({ty:"no"}),s.data.shapes[0].it.push({p:{k:[0,0],a:0},s:{k:[100,100],a:0},a:{k:[0,0],a:0},r:{k:0,a:0},o:{k:100,a:0},sk:{k:0,a:0},sa:{k:0,a:0},ty:"tr"})))}}}}(),u=function(){var e=[5,7,15];function t(e){var t=e.t.p;"number"==typeof t.a&&(t.a={a:0,k:t.a}),"number"==typeof t.p&&(t.p={a:0,k:t.p}),"number"==typeof t.r&&(t.r={a:0,k:t.r})}function r(e){var r,n=e.length;for(r=0;r<n;r+=1)5===e[r].ty&&t(e[r])}return function(t){if(a(e,t.v)&&(r(t.layers),t.assets)){var n,i=t.assets.length;for(n=0;n<i;n+=1)t.assets[n].layers&&r(t.assets[n].layers)}}}(),c=function(){var e=[4,1,9];function t(e){var r,n,i,s=e.length;for(r=0;r<s;r+=1)if("gr"===e[r].ty)t(e[r].it);else if("fl"===e[r].ty||"st"===e[r].ty){if(e[r].c.k&&e[r].c.k[0].i)for(n=0,i=e[r].c.k.length;n<i;n+=1)e[r].c.k[n].s&&(e[r'... 300774 more characters,
16:47:06.502 namespace: '',
16:47:06.502 suggestion: ''
16:47:06.503 },
16:47:06.503 notes: [
16:47:06.503 {
16:47:06.503 location: null,
16:47:06.503 text: 'You can read more about direct eval and bundling here: https://esbuild.github.io/link/direct-eval'
16:47:06.503 }
16:47:06.503 ],
16:47:06.503 pluginName: '',
16:47:06.503 text: 'Using direct eval with a bundler is not recommended and may cause problems'
16:47:06.503 }
16:47:06.504 ]
16:47:06.504 }
16:47:06.504