turbo icon indicating copy to clipboard operation
turbo copied to clipboard

[Turbopack] Libraries depending on node-gyp-build fail parsing

Open Escapado opened this issue 3 years ago • 1 comments
trafficstars

What version of Turbopack are you using?

latest alpha

What package manager are you using / does the bug impact?

pnpm, Yarn v1

What operating system are you using?

Linux

Describe the Bug

When using a package which depends on node-gyp-build (such as the supabase-js client), turbopack can't compile the app.

It fails with the following output:

error - [resolve] [project-with-next]/node_modules/node-gyp-build/index.js  Error resolving commonjs request
  unable to resolve dynamic
  
  | It was not possible to find the requested file.
  | Parsed request as written in source code: dynamic
  | Path where resolving has started: [project-with-next]/node_modules/node-gyp-build/index.js
  | Type of request: commonjs request

when I run next dev --turbo --show-all I additionally get this info:

error - [resolve] node_modules/node-gyp-build/index.js
  Error resolving commonjs request
  unable to resolve dynamic

[parse]
  node_modules/node-gyp-build/index.js
    node_modules/node-gyp-build/index.js:22:9  lint TP1002 require(???*0*) is very dynamic
        18   
        19   module.exports = load
        20   
        21   function load (dir) {
        22 >   return runtimeRequire(load.path(dir))
        23   }
        24   
        25   load.path = function (dir) {
        26     dir = path.resolve(dir || '.')
    
    - *0* ???*1*(???*2*)
      ⚠️  call of unknown function
    - *1* (...) => (??? | ???)["path"]
      ⚠️  property on function
    - *2* arguments[0]
      ⚠️  cross function analyzing is not yet supported

Expected Behavior

Importing packages which depend on node-gyp-build should work.

To Reproduce

Checkout the repo below. It's an exceedingly minimal Next 13 project. next dev works as intended. next dev --turbo will produce the aforementioned error.

Reproduction Repo

https://github.com/Escapado/next-turbo-bug

Escapado avatar Oct 25 '22 23:10 Escapado

+1 here with the Supabase client

animify avatar Oct 26 '22 10:10 animify

This is a serious blocker

pauliusuza avatar Jan 24 '23 23:01 pauliusuza

Any idea how solve this error ?

st1ng7ay avatar Mar 28 '23 10:03 st1ng7ay

Any update on this? Still seeing the issue a year later!

nathaneidelson avatar Aug 22 '23 23:08 nathaneidelson

still not work in next 13.5

boredjoker avatar Sep 22 '23 09:09 boredjoker

Seeing this in [email protected]

baufometic avatar Sep 23 '23 13:09 baufometic

Still happening on Next 14

mblode avatar Oct 27 '23 05:10 mblode

Yes, Next 14 have this problem

AlexDrags avatar Nov 03 '23 09:11 AlexDrags

Yep, still happening on Next 14.0.2

buzzthedev avatar Nov 12 '23 00:11 buzzthedev

Kind of hilariously bad that @vercel/[email protected] (Vercel's own package) breaks Turbopack when using [email protected] with this error. Y'all really need to do some testing before releasing.

ameyer117 avatar Nov 14 '23 16:11 ameyer117

Massive blocker here. Unable to use supabase inside components due to this weird error.

I'm using pnpm.

Module not found
It was not possible to find the requested file.
    Parsed request as written in source code: dynamic
    Path where resolving has started: [project]/node_modules/.pnpm/[email protected]/node_modules/node-gyp-build/node-gyp-build.js
    Type of request: commonjs request
    Import map: No import map entry
    


 ⨯ ModuleBuildError: error - node_modules/.pnpm/[email protected]/node_modules/node-gyp-build/node-gyp-build.js:22:9

sannajammeh avatar Nov 16 '23 04:11 sannajammeh

Still happening in Next 14.0.3

AaronHernandezPerez avatar Nov 27 '23 18:11 AaronHernandezPerez

same problem next 14.0.3

lucaspereirasouzat avatar Dec 01 '23 17:12 lucaspereirasouzat

Same

joacub avatar Dec 02 '23 04:12 joacub

Can confirm this is still an issue with the latest supabase library + nextJS 14.0.3.

captainsloths avatar Dec 04 '23 20:12 captainsloths

Even with @vercel/[email protected] also

CleanShot 2023-12-05 at 16 37 53

Would be great there's a work around for this.

BennyKok avatar Dec 05 '23 08:12 BennyKok

Just tested, Next.js 14.0.4 fixes this. Sadly, I'm stuck on Next.js 14.0.3 because Mongoose library does not work with Next.js 14.0.4, therefore I cannot use Turbopack. What a headache man...

Edit: Next.js 14.0.4-canary.37 is the only latest version that works for me as explained here.

edxeth avatar Dec 16 '23 11:12 edxeth

This is finally fixed with Next 14.0.4! 🥳

mblode avatar Dec 17 '23 10:12 mblode

Yeah, fixed!

porkopek avatar Dec 17 '23 22:12 porkopek

Closing as fixed. Thank you for trying!

kdy1 avatar Dec 21 '23 09:12 kdy1