webpack-contrib / node-loader

node loader for native modules
MIT License
119 stars 43 forks source link

dlopen: relative path => absolute path #135

Closed Maxxxz closed 1 month ago

Maxxxz commented 5 months ago

This PR contains a:

Motivation / Use-Case

When require a [.node] file within a [.asar] package, there is an unexpected issue with the Mac system. The error message states:

Error: dlopen(/Applications/xx.app/Contents/Resources/app/application.asar//../wrapper.node, 0x0001): 
tried: '/Applications/xx.app/Contents/Resources/app/application.asar//../wrapper.node' (errno=20), 
'/System/Volumes/Preboot/Cryptexes/OS/Applications/xx.app/Contents/Resources/app/application.asar//../wrapper.node' (no such file),
'/Applications/xx.app/Contents/Resources/app/application.asar//../wrapper.node'(errno=20)

However, it can be opened when using the absolute path: /Applications/xx.app/Contents/Resources/app/wrapper.node To resolve this, I've used path.join to format the path.

similar issue: https://github.com/webpack-contrib/node-loader/issues/132

Breaking Changes

no

Additional Info

linux-foundation-easycla[bot] commented 5 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

Maxxxz commented 5 months ago

Looks good, can you add a test case?

Sure, i update the snapshot. it should cover this case.

SlyryD commented 1 month ago

This change looks like it would help me too. Please merge!