'Build error after updating Svelte: Package subpath './compiler.js' is not defined by "exports"
Problem
I was on Svelte version 3.0.0 and used npm i svelte@latest
to update to the most recent version. Now I can't get the app to run, I always get this errror:
[!] Error: Package subpath './compiler.js' is not defined by "exports" in /home/blub/coding/bla/node_modules/svelte/package.json Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './compiler.js' is not defined by "exports" in /home/blub/coding/bla/node_modules/svelte/package.json
Failed Solutions
I also updated rollup-plugin-svelte to version 5.2.0, but that did not help. Are there any other dependencies I also have to update? Here is a list of my dependencies:
"devDependencies": {
"node-sass": "^4.12.0",
"npm-run-all": "^4.1.5",
"rollup": "^2.44.0",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-svelte": "^5.2.3",
"rollup-plugin-terser": "^4.0.4",
"svelte": "^3.37.0",
"svelte-preprocess-sass": "^0.2.0"
},
"dependencies": {
"axios": "^0.19.0",
"sirv-cli": "^0.4.4"
},
Solution 1:[1]
This issue is due to a breaking change of svelte v3.29.5
. So if you want to use this version you will also need to update rollup-plugin-svelte
to at least v6.1.1
:
npm i -D [email protected]
# or with yarn
yarn add -D [email protected]
Solution 2:[2]
I had an old Svelte project and did not have time to update it all. I found downgrading Svelte to 3.29.4 fixed the issue.
npm i -D [email protected]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Jared Christensen |