报错信息 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/arrayWithHoles.js
require() of ES modules is not supported.
require() of /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/arrayWithHoles.js from /Users/wanglei/Documents/Projects/ssr-test/build/index/server/Page.server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename arrayWithHoles.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/package.json.
报错信息 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/arrayWithHoles.js require() of ES modules is not supported. require() of /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/arrayWithHoles.js from /Users/wanglei/Documents/Projects/ssr-test/build/index/server/Page.server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename arrayWithHoles.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/wanglei/Documents/Projects/ssr-test/nodemodules/@babel_runtime@7.12.1@@babel/runtime/helpers/esm/package.json.
复现方法 https://github.com/ykfe/ssr#%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE 使用 npm 模板生成的项目就会出现问题
OS: macOS 10.14/15 node: v12.19.0 npm: 6.14.8
大概是在 @babel/runtime 这个库升级到 7.12.1 的时候出现的,看报错是说 Page.server.js 内用 require 引入了 esm 的模块