Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find package 'stream' #2412

Closed
winston0410 opened this issue Sep 12, 2021 · 16 comments
Closed

Cannot find package 'stream' #2412

winston0410 opened this issue Sep 12, 2021 · 16 comments
Milestone

Comments

@winston0410
Copy link

Describe the bug

This happens after the latest update for kit. I got the following error with npm run build:

19:39:57.691 > Cannot find package 'stream' imported from /vercel/path0/web/.svelte-kit/output/server/app.js
19:39:57.691 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'stream' imported from /vercel/path0/web/.svelte-kit/output/server/app.js
19:39:57.691 at packageResolve (internal/modules/esm/resolve.js:664:9)
19:39:57.691 at moduleResolve (internal/modules/esm/resolve.js:705:18)
19:39:57.691 at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:819:11)
19:39:57.691 at Loader.resolve (internal/modules/esm/loader.js:89:40)
19:39:57.691 at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
19:39:57.691 at ModuleWrap. (internal/modules/esm/module_job.js:73:40)
19:39:57.691 at link (internal/modules/esm/module_job.js:72:36)

Reproduction

Clone my repo here: https://github.com/winston0410/portfolio-2021

cd ./web
npm install
npm run build

Logs

No response

System Info

System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 27.66 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.4.1 - /nix/store/i0sl2paxrjshqn5ps24pdhdkql07x6ra-nodejs-16.4.1/bin/node
    npm: 7.18.1 - /nix/store/i0sl2paxrjshqn5ps24pdhdkql07x6ra-nodejs-16.4.1/bin/npm
  Browsers:
    Brave Browser: 93.1.29.76
    Safari: 14.1.1
  npmPackages:
    @sveltejs/adapter-static: next => 1.0.0-next.18
    @sveltejs/adapter-vercel: next => 1.0.0-next.28
    @sveltejs/app-utils: next => 1.0.0-next.3
    @sveltejs/kit: next => 1.0.0-next.162
    svelte: ^3.34.0 => 3.42.4

Severity

blocking all usage of SvelteKit

Additional Information

I got the same error on both local and vercel.

@benmccann benmccann changed the title [static-adaptor] Cannot find package 'stream' [adapter-static] Cannot find package 'stream' Sep 13, 2021
@benmccann benmccann added this to the 1.0 milestone Sep 13, 2021
@benmccann benmccann changed the title [adapter-static] Cannot find package 'stream' Cannot find package 'stream' Sep 14, 2021
@benmccann
Copy link
Member

I think that import statement is coming from node-fetch. We haven't changed the node-fetch version in many months though

This happens after the latest update for kit.

This doesn't seem to have broken because of a kit upgrade, but because of winston0410/portfolio-2021@859ead8#diff-4b5e57f6eb2f42b9039b3d1e13929295f231749c510cbe341cd68036d9af97e2

@benmccann
Copy link
Member

It's because you added a dependency on node-fetch 3.0 final. I get the same error if I try to upgrade SvelteKit to use that version: #2422

@winston0410
Copy link
Author

@benmccann Yes I have added in node-fetch, because I got an ERR_MODULE_NOT_FOUND for fetch in my server side code.

And I think I got that error after I have added in a wrapped fetch to my code, but it looks alright to me? It should pick up fetch from either global or window?

// index.ts
var createWrapped = (f) => {
  f = f ? f : fetch;
  return async (url, opts) => {
    const res = await f(url, opts);
    return {
      ok: res.ok,
      status: res.status,
      body: await res.json()
    };
  };
};
var git_clone_aa4ce5db_default = createWrapped;
export {
  git_clone_aa4ce5db_default as default
};

@winston0410
Copy link
Author

#2422

I hope this will solve the issue. Thank you for your time for helping me out.

@benmccann
Copy link
Member

You must set ignoreTryCatch: true for @rollup/plugin-commonjs: rollup/plugins#1004

@asdfdelta
Copy link

I found a decent work-around since updating Kit wasn't working for me. Downgrading to version 2.6.5 of node-fetch solved all errors.

npm I node-fetch@2.6.5

@benmccann
Copy link
Member

I got fixes into @rollup/plugin-commonjs, @sveltejs/kit, and vite for this issue. Can you try upgrading to 1.0.0-next.180 which I just released?

@renefournier
Copy link

Updated, still seeing

Hashing _app/assets/start-61d1577b.css    Error: In file "/Users/rene/Sites/work/r2creative/smile-forms/app/.netlify/funct
    ions-internal/__render.js"
    Cannot find module 'stream/package.json'

when npm run build && netlify deploy. Hmm.. (But thanks for the efforts @benmccann !)

@benmccann
Copy link
Member

This sounds like a duplicate of #2523. Let's track it there

@jckr
Copy link

jckr commented Jul 7, 2022

fwiw, i had a similar error message while accidentally using an old version of node. if you find this page by googling "Cannot find package 'stream' " with sveltekit, that's something you may want to check.

@DavidM42
Copy link

I can support @jckr's advice. Was using node version 14 when I got this error.
Updating to the current node version 18.6.0 solved it 👍

@hperrin
Copy link

hperrin commented Jul 22, 2022

I ran into this too. Upgrading to 16 worked, but unfortunately, that really complicates my setup, as I have other things that require Node 14.

@dominikg
Copy link
Member

I ran into this too. Upgrading to 16 worked, but unfortunately, that really complicates my setup, as I have other things that require Node 14.

kit requires node 16

"node": ">=16.9"

@benmccann
Copy link
Member

Using multiple node versions is easy with nvm: https://github.com/nvm-sh/nvm

@rainrisa
Copy link

i had the same issue, my node version is 16.13.0

@rainrisa
Copy link

solved by this octokit/octokit.js#2126 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants