Next.js Discord

Discord Forum

serverExternalPackages not recognized in next.config.mjs (Next 14)

Unanswered
Yucatan Vireo posted this in #help-forum
Open in Discord
Avatar
Yucatan VireoOP
I'm trying to use the @node-rs/argon2 package by including it in my Next config next.config.mjs . This method is included in the documentation here: https://nextjs.org/docs/app/api-reference/next-config-js/serverExternalPackages
Including this package gives me the following error:

./node_modules/@node-rs/argon2-win32-x64-msvc/argon2.win32-x64-msvc.node
Module parse failed: Unexpected character '�' (1:2)
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)

I am not familiar with loaders, so I won't attempt to use one without consulting the forum first. I solved this issue initially by upgrading to Next 15, but this is no longer an option for me. It seems my version (14.x) is potentially the problem. If anyone has any ideas about how to fix this, I would greatly appreciate it. I am hoping it is possible to use this package in this version.

Here is my config for reference:

/** @type {import('next').NextConfig} */
const nextConfig = {
  serverExternalPackages: ["argon2"],
  // ...
};

export default nextConfig;

0 Replies