I have a package that I'm importing into my Next.js project (v13.4.3) that has a sub-dependency on another package which supplies it with translations via a JSON file. However, when I attempt to use the package and compile, I get this error:
- info Collecting page data ..Error: Cannot find module '/Users/user/app/.next/server/chunks/translations.json'
at webpackEmptyContext (/Users/user/app/.next/server/chunks/7208.js:9:10)
at Object.9641 (/Users/user/app/.next/server/chunks/9716.js:10551:45)
at __webpack_require__ (/Users/user/app/.next/server/webpack-runtime.js:25:42)
at Object.11450 (/Users/user/app/.next/server/chunks/9716.js:5138:31)
at __webpack_require__ (/Users/user/app/.next/server/webpack-runtime.js:25:42)
at Object.4847 (/Users/user/app/.next/server/chunks/9716.js:5309:14)
at __webpack_require__ (/Users/user/app/.next/server/webpack-runtime.js:25:42)
at Object.59204 (/Users/user/app/.next/server/chunks/9716.js:6898:14)
at __webpack_require__ (/Users/user/app/.next/server/webpack-runtime.js:25:42)
at /Users/user/app/.next/server/pages/projects/[id].js:27:79 {
code: 'MODULE_NOT_FOUND'
}
When I go into the actual node_module folder, the .json file is indeed there. Might be worth noting that both packages belong to an NPM scope (e.g. @mycompany
), which was added to transpilePackages
array as ["@mycompany"]
to prevent a separate error I was getting that said SyntaxError: Unexpected token 'export'
. I also tried using Remix.run to see if it would work there, but I ended up getting an identical error message.
How should I go about fixing this?