Encountering an error during production build. Here's the output of npm run build
executed on Node v16.20.1
npm run build
> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7a6c6a317a757278796e5c2c322c322d">[email protected]</a> build
> vite build
vite v4.4.9 building SSR bundle for production...
✓ 123 modules transformed.
node:internal/event_target:1011
process.nextTick(() => { throw err; });
^
file:///Users/luca/Projects/personal/fpv-finder/.svelte-kit/output/server/chunks/runtime.esm.js:3
import { IntlMessageFormat } from "intl-messageformat";
^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'IntlMessageFormat' not found. The requested module 'intl-messageformat' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'intl-messageformat';
const { IntlMessageFormat } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async analyse (file:///Users/luca/Projects/personal/fpv-finder/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js:60:16)
at async MessagePort.<anonymous> (file:///Users/luca/Projects/personal/fpv-finder/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
Emitted 'error' event on Worker instance at:
at Worker.[kOnErrorMessage] (node:internal/worker:298:10)
at Worker.[kOnMessage] (node:internal/worker:309:37)
at MessagePort.<anonymous> (node:internal/worker:205:57)
at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:736:20)
at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
The issue stems from this generated code.
import { d as derived, w as writable } from "./index.js";
import deepmerge from "deepmerge";
import { IntlMessageFormat } from "intl-messageformat"; // <- This is the issue
function delve(obj, fullKey) {
if (fullKey == null)
return void 0;
if (fullKey in obj) {
return obj[fullKey];
}
// [...] Other code here
Is there a way to resolve this error?
Here's the package.json file content:
{
"name": "fpv-finder",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
...
},
"devDependencies": {
...
},
"type": "module",
"dependencies": {
"svelte-i18n": "^3.7.4"
}
}
Steps followed include executing npm run build
with the expectation of successful project compilation.