kit: bug(netlify): Package subpath './hooks' is not defined by "exports"

Describe the bug

Sveltekit app having version “svelte”: “^3.44.0” works perfectly locally but showing “errorMessage”:“Package subpath ‘./ssr’ is not defined by "exports" in /var/task/node_modules/@sveltejs/kit/package.json” when deployed to production on netlify. I have tried both auto-adapter and explicit netlify adapter but the error persists.

Reproduction

Repo link: https://github.com/Mrbeyond/pubside

Logs

{"errorType":"Error","errorMessage":"Package subpath './ssr' is not defined by \"exports\" in /var/task/node_modules/@sveltejs/kit/package.json","trace":["Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ssr' is not defined by \"exports\" in /var/task/node_modules/@sveltejs/kit/package.json","    at new NodeError (internal/errors.js:322:7)","    at throwExportsNotFound (internal/modules/esm/resolve.js:322:9)","    at packageExportsResolve (internal/modules/esm/resolve.js:511:7)","    at resolveExports (internal/modules/cjs/loader.js:450:36)","    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)","    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)","    at Function.Module._load (internal/modules/cjs/loader.js:746:27)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Object.<anonymous> (/var/task/.netlify/server/app.js:45:29)"]}

System Info

"devDependencies": {
    "@sveltejs/adapter-auto": "next",
    "@sveltejs/adapter-netlify": "^1.0.0-next.37",
    "@sveltejs/kit": "next",
    "autoprefixer": "^10.4.1",
    "cssnano": "^5.0.14",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-svelte3": "^3.2.1",
    "node-sass": "^7.0.1",
    "postcss-load-config": "^3.1.0",
    "prettier": "^2.4.1",
    "prettier-plugin-svelte": "^2.4.0",
    "svelte": "^3.44.0",
    "svelte-preprocess": "^4.10.1",
    "tailwindcss": "^3.0.8"
  },

Severity

annoyance

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

@sveltejs/kit/ssr was introduced 10 months ago in https://github.com/sveltejs/kit/pull/454. But I guess that it ended up getting bundled via esbuild, so there was no issue. And then #2931 removed the second bundling step.

I agree that bundling @svelte/kit/ssr so that it exports CJS as well seems like perhaps the best solution

I completely disagree @bluwy. Even with your ‘fix’, there is no change. This is an issue with the netlify adapter for Svelte, who else would be responsible for such an issue?

Can you show what is the issue with the Netlify adapter? The export error doesn’t make sense as we had always exported the ./ssr path. It’s hard to debug this issue as the build works locally, and only fails in Netlify, which could likely mean the issue is within Netlify.

There has been many reports with Netlify and its cache issue recently. Can you try clearing the cache on netlify and re-deploy again?

Go to your the Netlify dashboard, and to your website’s deploy page. Click “Clear cache and deploy site”: image

I don’t see anything else SvelteKit can help on this.

exactly the same issue here

in my experience the netlify adapter has always been subpar and broken/not prod ready compared to vercel which is sad 😦 every time i try to deploy a site that relies on ssr to netlify it fails in some way or another and i keep going back to vercel

./ssr is definitely defined in package.json. Can you confirm the @sveltejs/kit version from the lockfile? The next version is vague. I also can’t access the repo to verify it.

Repo: https://github.com/Mrbeyond/pubside