Skip to content

Commit 38f5707

Browse files
committed
put check inside get_node_version
1 parent aa396c2 commit 38f5707

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/adapter-vercel/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ export default function ({ external = [], edge, split } = {}) {
8686
name: '@sveltejs/adapter-vercel',
8787

8888
async adapt(builder) {
89-
const nodeVersion = getNodeVersion();
90-
if (nodeVersion.major < 14) {
91-
throw new Error(
92-
`SvelteKit only support Node.js version 14 or greater (v${nodeVersion.full} was detected). Learn how to change the Node.js version of your Functiones here: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version`
93-
);
94-
}
95-
9689
if (process.env.ENABLE_VC_BUILD) {
9790
await v3(builder, external, edge, split);
9891
} else {
@@ -394,12 +387,12 @@ function write(file, data) {
394387
writeFileSync(file, data);
395388
}
396389

397-
function getNodeVersion() {
390+
function get_node_version() {
398391
const full = process.version.slice(1); // 'v16.5.0' --> '16.5.0'
399392
const major = parseInt(full.split('.')[0]); // '16.5.0' --> 16
400393

401-
if (!Number.isFinite(major)) {
402-
throw new Error('There was an error getting the current Node version');
394+
if (major < 14) {
395+
throw new Error(`SvelteKit only support Node.js version 14 or greater (currently using v${full}). Consult the documentation: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version`)
403396
}
404397

405398
return { major, full };

0 commit comments

Comments
 (0)