- 将 serverless 函数中的
import foo from './foo'修改为
import foo from './foo.js'
.js/.mjs 扩展名。TypeScript 编译器兼容该规范，导本地模块的时候加一个
.js 扩展名就 OK 了
VERCEL_CLI_VERSION environment variable to the previous CLI verison
We are locking this thread now to avoid confusion. As a next step:
We have an update from our engineer that may fix your issue and allow you to remove the CLI variable:
"module": "esnext" (or
"module": "nodenext") must also have
If you run into a problem, it will likely be at runtime and look something like:
ReferenceError: require is not defined in ES module scope, you can use import instead
If you want to continue using CommonJS instead of ES Modules, the solution would be to update your
tsconfig.json file with
Also note that TypeScript will allow you to mix CJS and ESM, however Node.js will not. So you cannot use
import() in the same file, and you cannot use
export default and
module.exports in the same file.
If you are still facing issue with above configuration, please reach out to Vercel Support with following information:
- contents of
- the runtime error message (we can find this if you provide deployment url)
- the contents of the file that failed (the file will be mentioned in the error message)
If you have set any Environment variable to use previous version of Vercel CLI, please ensure you remove it to get future updates of our Vercel builder. Thank you!