There are no errors when launching the application, and the application functions normally, but if you log in to the server logs, a permanent error appears.
Error in the logs:
2024-03-23_04:59:51.32690 Sleep 60 secs. before restart due to previous errors...
2024-03-23_05:15:46.84825 node:internal/modules/esm/assert:88
2024-03-23_05:15:46.84833 throw new ERR_IMPORT_ATTRIBUTE_MISSING(url, 'type', validType);
2024-03-23_05:15:46.84834 ^
2024-03-23_05:15:46.84835
2024-03-23_05:15:46.84835 TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///home/с123123/с123123.ru/app/package.json" needs an import attribute of "type: json"
2024-03-23_05:15:46.84836 at validateAttributes (node:internal/modules/esm/assert:88:15)
2024-03-23_05:15:46.84837 at defaultLoad (node:internal/modules/esm/load:153:3)
2024-03-23_05:15:46.84837 at async ModuleLoader.load (node:internal/modules/esm/loader:403:7)
2024-03-23_05:15:46.84838 at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)
2024-03-23_05:15:46.84838 at async link (node:internal/modules/esm/module_job:78:21) {
2024-03-23_05:15:46.84839 code: 'ERR_IMPORT_ATTRIBUTE_MISSING'
2024-03-23_05:15:46.84839 }
2024-03-23_05:15:46.84840
2024-03-23_05:15:46.84841 Node.js v21.7.1
2024-03-23_05:15:48.05344 Sleep 60 secs. before restart due to previous errors...
package.json :
"name": "sveltekit-gun-example",
"version": "1.0.0",
"scripts": {
"dev": "node server/dev/index.js",
"build": "vite build",
"start": "node server/index.js",
"preview": "node server/index.js",
"build:preview": "npm run build && npm run start",
"test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@playwright/test": "^1.37.1",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.5.0",
"@types/express": "^4.17.17",
"autoprefixer": "^10.4.15",
"postcss": "^8.4.29",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.2.0",
"svelte-check": "^3.5.1",
"tailwindcss": "^3.3.3",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
},
"type": "module",
"dependencies": {
"@floating-ui/dom": "^1.5.1",
"@sentry/sveltekit": "^7.61.1",
"esm": "^3.2.25",
"express": "^4.18.2",
"flowbite": "^2.0.0",
"flowbite-svelte": "^0.44.2",
"gun": "^0.2020.1239",
"svelte-local-storage-store": "^0.6.0",
"tailwind-merge": "^2.0.0",
"unique-username-generator": "^1.2.0"
}
}
Module type: Your package file.json requires the import attribute “type:json". Make sure that in the package file.json has a corresponding attribute.
Somewhere you are importing package.json and trying to use some of it's properties.
Per: Fully Stacked:
For security reasons (a file extension alone is not a reliable enough indicator of the content type) you have to specify the type using with
{type: "json"}.
so instead use (for example):
import pkg from "./package.json" with { type: "json" };
Note also the comment above and consider handling the case where the file (package.json in this example) is missing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With