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

vite-node — TypeError: p.closeBundle.call is not a function #1960

Closed
6 tasks done
acarl005 opened this issue Sep 2, 2022 · 8 comments
Closed
6 tasks done

vite-node — TypeError: p.closeBundle.call is not a function #1960

acarl005 opened this issue Sep 2, 2022 · 8 comments

Comments

@acarl005
Copy link

acarl005 commented Sep 2, 2022

Describe the bug

This error gets thrown at the end of my script when i run vite-node from the command line.

TypeError: p.closeBundle.call is not a function
    at eval (file:///home/projects/sveltejs-kit-template-default-t83pry/node_modules/vite-node/node_modules/vite/dist/node/chunks/dep-0fc8e132.js:35663:81)
    at Array.map (<anonymous>)
    at Object.close (file:///home/projects/sveltejs-kit-template-default-t83pry/node_modules/vite-node/node_modules/vite/dist/node/chunks/dep-0fc8e132.js:35663:39)
    at async Promise.all (index 2)
    at async Object.close (file:///home/projects/sveltejs-kit-template-default-t83pry/node_modules/vite-node/node_modules/vite/dist/node/chunks/dep-0fc8e132.js:59298:13)
    at async CAC.run (file:///home/projects/sveltejs-kit-template-default-t83pry/node_modules/vite-node/dist/cli.mjs:684:5)

See my repro and run chmod +x ./scripts/run.sh && npm run foo.

Reproduction

See my repro and run chmod +x ./scripts/run.sh && npm run foo.

I added a console.log(p.closeBundle) to see why call isn't a function, and this is what is printed:

{ sequential: true, handler: [AsyncFunction: handler] }

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vite: ^3.1.0-beta.1 => 3.1.0-beta.2

Used Package Manager

npm

Validations

@acarl005 acarl005 changed the title TypeError: p.closeBundle.call is not a function vite-node — TypeError: p.closeBundle.call is not a function Sep 2, 2022
@sheremet-va
Copy link
Member

sheremet-va commented Sep 3, 2022

vite-node defines its Vite version as ^2.9.12 || ^3.0.0-0, so any Vite 3 version is compatible with it. I assume you installed a new Vite version, but for some reason vite-node kept its local old version. Try updating your package-lock.

@dominikg
Copy link
Contributor

dominikg commented Sep 3, 2022

latest version of SvelteKit is already using vite 3.1.0-beta and the new object-style hook syntax from rollup 2.78.0.

rollup/rollup#4600

I guess vite-node needs to support it by checking for hook.handler too

@sheremet-va
Copy link
Member

sheremet-va commented Sep 3, 2022

I guess vite-node needs to support it by checking for hook.handler too

Vite-node doesn't call this code. You can see in the stack trace that it just runs Vite. @acarl005 has several Vite versions installed, and vite-node uses its local Vite version, which I assume is lower than 3.1.0

@acarl005
Copy link
Author

acarl005 commented Sep 3, 2022

Ah yes that's correct. According to the package-lock.json...

"node_modules/vite": {
  "version": "3.1.0-beta.2"
},
"node_modules/vite-node/node_modules/vite": {
  "version": "3.0.9"
}

I see that the version spec for vite in the vite-node package.json is "vite": "^2.9.12 || ^3.0.0-0". If I understand NPM's versioning semantics, this means beta versions of Vite cannot be used with vite-node? So the solution here would be to wait until Sveltekit is able to run on the stable version of Vite instead of the beta?

@sheremet-va
Copy link
Member

If I understand NPM's versioning semantics, this means beta versions of Vite cannot be used with vite-node?

Do you have any source on that? According to the link I mentioned, it satisfies semver.

@acarl005
Copy link
Author

acarl005 commented Sep 3, 2022

@sheremet-va It seems the official semantic versioner output is different. Check out this code snippet.

const semver = require('semver')
semver.satisfies("3.1.0-beta.2", "^3.0.0-0") // false
semver.satisfies("3.0.0-beta.2", "^3.0.0-0") // true

According to the NPM docs, that is the official package used to determine semver compatibility.

I found an explanation of this behavior in the source code, and in the docs.

Basically, it looks like it is impossible to opt-in to all prerelease versions within a range, even if your range is *! You can only opt-in to prerelease versions of a specific patch version, i.e. ^3.0.0-0 covers all prerelease versions of 3.0.0, but none of the prerelease versions of 3.1.x, 3.2.x, etc...

@sheremet-va
Copy link
Member

Basically, it looks like it is impossible to opt-in to all prerelease versions within a range, even if your range is *!

I guess the only way to test beta versions would be to use overrides (for NPM) field then.

I don't think we can put every beta version 😄 If this satisfies you, we can close the issue.

@acarl005
Copy link
Author

acarl005 commented Sep 3, 2022

Yep that works! Thanks for your help!

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

No branches or pull requests

3 participants