snappy icon indicating copy to clipboard operation
snappy copied to clipboard

Docs: Add a section to explain how to make it work with nextjs and/or webpack

Open giancarlosisasi opened this issue 1 year ago • 3 comments

Hi there

I'm using nextjs and winston-loki which has snappy has a peerDependency, and I'm getting the following error:

error - ../../node_modules/.pnpm/@[email protected]/node_modules/@napi-rs/snappy-darwin-arm64/snappy.darwin-arm64.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently, no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Import trace for requested module:
../../node_modules/.pnpm/@[email protected]/node_modules/@napi-rs/snappy-darwin-arm64/snappy.darwin-arm64.node
../../node_modules/.pnpm/[email protected]/node_modules/snappy/index.js
../../node_modules/.pnpm/[email protected]/node_modules/winston-loki/src/batcher.js
../../node_modules/.pnpm/[email protected]/node_modules/winston-loki/index.js
../../packages/next/dist/logger/index.js
../../packages/next/logger/index.mjs
./src/views/Homepage/server/getServerSideProps.tsx
./src/views/Homepage/index.ts

I think the error is because nextjs/webpack doesn't know how to process a file with an extension .node. Maybe we can add, in the readme file, a section about how to fix this problem? 🤔 I have found this webpack-loader but I don't know if this is the recommended way.

Thanks.

SO: macOS package manager: pnpm v7.18.0 winston: "v3.8.2", winston-loki: "v6.0.6" snappy: 7.1.1

giancarlosisasi avatar Mar 02 '23 17:03 giancarlosisasi

After implementing the node-loader, now I get these errors:

image

giancarlosisasi avatar Mar 02 '23 20:03 giancarlosisasi

@GiancarlosIO -- did you ever get this to work? I'm facing the same problem trying to use nextjs + webpack.

kenirwin avatar Mar 06 '24 19:03 kenirwin

See https://github.com/napi-rs/use-napi-rs-packages-with-bundlers

Brooooooklyn avatar Mar 08 '24 12:03 Brooooooklyn