Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Module not found: Can't resolve '../build/Release/xxhash' #118

Open
isaced opened this issue Feb 17, 2024 · 6 comments
Open

Module not found: Can't resolve '../build/Release/xxhash' #118

isaced opened this issue Feb 17, 2024 · 6 comments

Comments

@isaced
Copy link

isaced commented Feb 17, 2024

 ⨯ ./node_modules/lz4/lib/utils.js:4:10
Module not found: Can't resolve '../build/Release/xxhash'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/lz4/lib/static.js
./node_modules/lz4/lib/lz4.js
./node_modules/@alicloud/gateway-sls-util/dist/client.js
./node_modules/@alicloud/gateway-sls/dist/client.js
./node_modules/@alicloud/sls20201230/dist/client.js
./lib/sls.ts
 ⨯ ./node_modules/lz4/lib/utils.js:4:10
Module not found: Can't resolve '../build/Release/xxhash'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/lz4/lib/static.js
./node_modules/lz4/lib/lz4.js
./node_modules/@alicloud/gateway-sls-util/dist/client.js
./node_modules/@alicloud/gateway-sls/dist/client.js
./node_modules/@alicloud/sls20201230/dist/client.js
./lib/sls.ts

ENV:

  • lz4: v0.6.5
  • node: v20.10.0
  • npm: 10.2.3
@RoboCafaz
Copy link

RoboCafaz commented Mar 7, 2024

Check your node_modules/lz4/build/Release folder. You should see an lz4.node and xxhash.node file in there. If not, try re-running npm install or yarn install.

You'll need to make sure whatever is running the environment recognizes those files as modules. For example, with jest you have to add node to the moduleFileExtensions list.

@Tukajo
Copy link

Tukajo commented Jul 23, 2024

Y'all ever get any further with this? @RoboCafaz, @isaced struggling with the same issue. I even tried wrapping some of the stuff manually and had no luck.

@isaced
Copy link
Author

isaced commented Jul 28, 2024

@Tukajo you can try this:

const nextConfig = {
  output: "standalone",
  experimental: {
    serverComponentsExternalPackages: ["lz4"],  // <-add this
  },
};

export default nextConfig;

@Tukajo
Copy link

Tukajo commented Jul 30, 2024

@isaced thanks for the suggestion!
I should have been more clear 🙂.

I'm actually just using a regular nodejs env. Trying to basically bundle an aws lambda. So no nextjs involved unfortunately.

@Andriy-Kulak
Copy link

@isaced thanks for the suggestion! I should have been more clear 🙂.

I'm actually just using a regular nodejs env. Trying to basically bundle an aws lambda. So no nextjs involved unfortunately.

@Tukajo any luck with solving this? i am having the same issue on lambda

@Tukajo
Copy link

Tukajo commented Aug 24, 2024

@Andriy-Kulak I went down a deep deep rabbithole that lead me to a circular series of threads where people were in a stalemate on resolving this.

Some folks were essentially arguing that this will not be implemented, since the new node fetch does not resolve local file URIs anymore as of the latest node versions. They refused to do it because various fetch specs from WinterCG specify that "file resolving" is left up to the reader as exercise see:
image
https://fetch.spec.wintercg.org/

I don't personally agree with this argument all that much since honestly it is surprising to me that node would allow file fetching up until now and basically break a ton of functionality. I don't know who's "problem" this is to fix.

Since there is this stalemate, and lz4 mostly relies on fetch resolving local wasm files for lz4, I don't foresee any fix any time soon.

I moved on to using different compression algorithms for my work that did not rely on local file fetching, or had out-of-the-box support for file fetching.

My use-case was identical to yours, this was lambda code.

Sorry I couldn't help more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants