首页 > 编程语言 >how to config `node.js` version in vercel All In One

how to config `node.js` version in vercel All In One

时间:2022-12-02 16:55:43浏览次数:70  
标签:node 01 35 js how webpack vercel

how to config node.js version in vercel All In One

image

Node.js engines & package.json

{
    "engines": {
      "node": "^8 || ^10"
    }
}

{
  "engines" : {
    "node" : ">=8.0.0 <11.0.0"
  }
}

=> 16.x ~ 18.x

{
  "engines" : {
    "node" : ">=16.14.0 <=18.12.0"
  }
}


error

[01:35:17.595] Cloning github.com/web-full-stack/nextjs-ssr (Branch: main, Commit: bc2ed05)
[01:35:18.521] Cloning completed: 925.235ms
[01:35:20.047] Skipping build cache since Node.js version changed from "16.x" to "18.x"
[01:35:20.477] Running "vercel build"
[01:35:20.988] Vercel CLI 28.6.0
[01:35:21.320] Installing dependencies...
[01:35:22.167] npm WARN EBADENGINE Unsupported engine {
[01:35:22.168] npm WARN EBADENGINE   package: '[email protected]',
[01:35:22.168] npm WARN EBADENGINE   required: { node: '>=16.14.0 <=18.12.0' },
[01:35:22.168] npm WARN EBADENGINE   current: { node: 'v18.12.1', npm: '8.19.2' }
[01:35:22.168] npm WARN EBADENGINE }
[01:35:29.134] 
[01:35:29.134] added 241 packages in 8s
[01:35:29.151] Detected Next.js version: 13.0.3
[01:35:29.154] Detected `package-lock.json` generated by npm 7+...
[01:35:29.155] Running "npm run build"
[01:35:29.458] 
[01:35:29.458] > [email protected] build
[01:35:29.458] > next build
[01:35:29.458] 
[01:35:29.913] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[01:35:29.913] This information is used to shape Next.js' roadmap and prioritize features.
[01:35:29.914] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[01:35:29.914] https://nextjs.org/telemetry
[01:35:29.914] 
[01:35:30.041] info  - Linting and checking validity of types...
[01:35:31.809] info  - Creating an optimized production build...
[01:35:36.346] Failed to compile.
[01:35:36.346] 
[01:35:36.346] node:fs/promises
[01:35:36.346] Module build failed: UnhandledSchemeError: Reading from "node:fs/promises" is not handled by plugins (Unhandled scheme).
[01:35:36.346] Webpack supports "data:" and "file:" URIs by default.
[01:35:36.346] You may need an additional plugin to handle "node:" URIs.
[01:35:36.347]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395974
[01:35:36.347]     at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28771), <anonymous>:6:1)
[01:35:36.347]     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:25925)
[01:35:36.347]     at Object.processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395899)
[01:35:36.347]     at processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:280173)
[01:35:36.348]     at iteratePitchingLoaders (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:279532)
[01:35:36.348]     at runLoaders (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:283436)
[01:35:36.348]     at NormalModule._doBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395761)
[01:35:36.348]     at NormalModule.build (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:397789)
[01:35:36.348]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:81243
[01:35:36.348] 
[01:35:36.349] Import trace for requested module:
[01:35:36.349] node:fs/promises
[01:35:36.349] ./utils/posts.js
[01:35:36.349] 
[01:35:36.349] node:fs
[01:35:36.350] Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
[01:35:36.350] Webpack supports "data:" and "file:" URIs by default.
[01:35:36.350] You may need an additional plugin to handle "node:" URIs.
[01:35:36.350]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395974
[01:35:36.350]     at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28771), <anonymous>:6:1)
[01:35:36.350]     at Object.processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395899)
[01:35:36.350]     at processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:280173)
[01:35:36.350]     at iteratePitchingLoaders (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:279532)
[01:35:36.350]     at runLoaders (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:1:283436)
[01:35:36.351]     at NormalModule._doBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395761)
[01:35:36.351]     at NormalModule.build (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:397789)
[01:35:36.351]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:81243
[01:35:36.351]     at NormalModule.needBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401868)
[01:35:36.351] 
[01:35:36.351] Import trace for requested module:
[01:35:36.351] node:fs
[01:35:36.351] ./utils/posts.js
[01:35:36.351] 
[01:35:36.352] 
[01:35:36.352] > Build failed because of webpack errors
[01:35:36.384] Error: Command "npm run build" exited with 1

https://vercel.com/web-full-stack/nextjs-ssr/6D6UAcLcfYZMPjAJ5Rv3M8ksaYor

https://www.cnblogs.com/xgqfrms/p/16943213.html#5130299

solutions

npm & package.json ✅

https://docs.npmjs.com/cli/v9/configuring-npm/package-json#dependencies

{
  "dependencies": {
    "foo": "1.0.0 - 2.9999.9999",
    "bar": ">=1.0.2 <2.1.2",
    "baz": ">1.0.2 <=2.3.4",
    "boo": "2.0.1",
    "qux": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0",
    "asd": "http://asdf.com/asdf.tar.gz",
    "til": "~1.2",
    "elf": "~1.2.3",
    "two": "2.x",
    "thr": "3.3.x",
    "lat": "latest",
    "dyl": "file:../dyl"
  }
}

https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies

semver / 语义化版本

https://github.com/npm/node-semver#versions

https://stackoverflow.com/questions/51596127/node-engine-8-x-or-10-x-in-package-json

https://www.marcusoft.net/2015/03/packagejson-and-engines-and-enginestrict.html

node.js

https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V14.md

vercel & Next.js

https://vercel.com/changelog/node-js-version-now-customizable-in-the-project-settings

https://vercel.com/changelog/node-js-16-lts-is-now-available

https://vercel.com/docs/concepts/functions/serverless-functions/runtimes

https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js

https://vercel.com/docs/concepts/functions/serverless-functions/runtimes#official-runtimes/node-js/node-js-version

(

标签:node,01,35,js,how,webpack,vercel
From: https://www.cnblogs.com/xgqfrms/p/16944941.html

相关文章