huggingface/transformers.js

bug: examples/next-server - Next Js Error on startup

Closed this issue · 4 comments

System Info

"@xenova/transformers": "^2.4.2",
"autoprefixer": "10.4.14",
"eslint": "8.45.0",
"eslint-config-next": "13.4.12",
"next": "^13.5.4",
"postcss": "^8.4.31",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3"

Using the default next-server example.
Using pnpm i

Environment/Platform

  • Website/web-app
  • Server-side (e.g., Node.js, Deno, Bun)

Description

Startup:
image

Then start typing in the input.

Next error:
image


image

After the app is initialized, this is error occurs after visiting the site at the designated port.

Thank you @xenova for everything you do for open source ML and AI. We appreciate you!

Reproduction

Start: From the main transformers.js folder

  1. cd examples/next-server
  2. pnpm i
  3. pnpm dev
  4. go to localhost:3000
  5. start typing

I've tried adding what I think are the external packages responsible for the error to an opt-out list but the error persists.

I followed the advice from Next found here:
serverExternalPackages


examples/next-server/next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
    // (Optional) Export as a standalone site
    // See https://nextjs.org/docs/pages/api-reference/next-config-js/output#automatically-copying-traced-files
    output: 'standalone', // Feel free to modify/remove this option
    
    // Indicate that these packages should not be bundled by webpack
    experimental: {
        serverComponentsExternalPackages: ['sharp', 'onnxruntime-node'],
    },

    // I ADDED THIS
    serverExternalPackages: ['@xenova/transformers', 'onnxruntime-node', 'node-loader'],
};

This seems related to
#210

and

#211

--

I'll look if there is an answer somewhere in these...

I'm seeing here that you called this out as a pnpm issue.
#210 (comment)

I'll start over and try this again with npm or yarn...

  1. delete node_modules
  2. installed using yarn install
  3. yarn dev

now it works

Definitely still not supported using pnpm.

Thanks @xenova !