Open lancejpollard opened 9 months ago
Also, when trying to build with Next.js pnpm build
, I am getting another error, if you have any ideas here, will post to the Next.js group:
Error: Expected to use Webpack bindings (react-server-dom-webpack/server.edge) for React but the current process is referencing 'createClientModuleProxy' from the Turbopack bindings (react-server-dom-turbopack/server.edge). This is likely a bug in our integration of the Next.js server runtime.
at Object.get (/app/node_modules/.pnpm/next@14.1.1-canary.27_@babel+core@7.22.10_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:366642)
at Object.<anonymous> (/app/.next/server/chunks/568bf_next_dist_78c2c7._.js:71:9)
at [project]/node_modules/.pnpm/next@14.1.1-canary.27_@babel+core@7.22.10_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/error-boundary.js (client proxy) (/app/.next/server/chunks/568bf_next_dist_78c2c7._.js:74:3)
at instantiateModule (/app/.next/server/chunks/[turbopack]_runtime.js:488:23)
at getOrInstantiateModuleFromParent (/app/.next/server/chunks/[turbopack]_runtime.js:539:12)
at esmImport (/app/.next/server/chunks/[turbopack]_runtime.js:113:20)
at /app/.next/server/chunks/568bf_next_dist_78c2c7._.js:78:312
at [project]/node_modules/.pnpm/next@14.1.1-canary.27_@babel+core@7.22.10_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/error-boundary.js [app-rsc] (ecmascript) (/app/.next/server/chunks/568bf_next_dist_78c2c7._.js:84:3)
at instantiateModule (/app/.next/server/chunks/[turbopack]_runtime.js:488:23)
at getOrInstantiateModuleFromParent (/app/.next/server/chunks/[turbopack]_runtime.js:539:12)
> Build error occurred
Error: Failed to collect page data for /
at /app/node_modules/.pnpm/next@14.1.1-canary.27_@babel+core@7.22.10_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/utils.js:1268:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
Could you provide your webpack config? Also, seeing that you are using next.js, you might find our next.js demo app/tutorial helpful.
My next.config.js
which contains my webpack config is like this:
/** @type {import('next').NextConfig} */
import nextTranspileModules from 'next-transpile-modules'
import createMDXPlugin from '@next/mdx'
import withYaml from 'next-plugin-yaml'
import path from 'path'
import { fileURLToPath } from 'url'
import remarkGfm from 'remark-gfm'
import remarkPrism from 'remark-prism'
import rehypeSlug from 'rehype-slug'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'
import autoprefixer from 'autoprefixer'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
if (
process.env.LD_LIBRARY_PATH == null ||
!process.env.LD_LIBRARY_PATH.includes(
`${process.env.PWD}/node_modules/canvas/build/Release:`,
)
) {
process.env.LD_LIBRARY_PATH = `${
process.env.PWD
}/node_modules/canvas/build/Release:${
process.env.LD_LIBRARY_PATH || ''
}`
}
const mdxConfig = {
extension: /\.mdx?$/,
options: {
providerImportSource: '@mdx-js/react',
rehypePlugins: [[rehypeSlug], [rehypeKatex]],
remarkPlugins: [[remarkPrism], [remarkMath], [remarkGfm]],
},
}
const withMDX = createMDXPlugin(mdxConfig)
const nextConfig = withYaml(
withMDX({
swcMinify: true,
optimizeFonts: false,
transpilePackages: [
'react-syntax-highlighter',
'pdfjs-dist',
],
pageExtensions: ['mdx', 'md', 'tsx', 'ts'],
poweredByHeader: false,
trailingSlash: false,
webpack: (config, options) => {
config.experiments = {
asyncWebAssembly: true,
syncWebAssembly: true,
layers: true,
topLevelAwait: true,
}
config.resolve.fallback = {
fs: false,
path: false,
dns: false,
net: false,
tls: false,
}
config.resolve = {
...config.resolve,
extensions: ['.ts', '.tsx', '.js', '.json', '.mjs'],
}
config.plugins ??= []
config.module.rules.push({
test: /\.mdx?$/,
use: [
// Note that Webpack runs right-to-left: `@mdx-js/loader` is used first, then
// `babel-loader`.
{ loader: 'babel-loader', options: {} },
{
loader: '@mdx-js/loader',
/** @type {import('@mdx-js/loader').Options} */
options: {},
},
],
})
config.resolve.alias.canvas = false
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
type: 'asset/source',
})
config.module.rules.push({
test: /\.(txt|node)$/,
loader: 'raw-loader',
})
return config
},
}),
)
export default nextConfig
@xenova the only thing I see in there might be:
config.resolve.fallback = {
fs: false,
path: false,
dns: false,
net: false,
tls: false,
}
I tried adding this, but still same error:
config.resolve = {
...config.resolve,
sharp$: false,
'onnxruntime-node$': false,
extensions: ['.ts', '.tsx', '.js', '.json', '.mjs'],
}
Question
I copied the code from https://github.com/xenova/transformers.js/blob/main/examples/remove-background-client/main.js to here, but I'm getting this error with v2.15.0 of @xenova/transformers.js:
Any idea what is wrong and how to fix it? Here is my code, which basically a direct React.js port of the background removal example you all shared: