要修复警告“(node:27976) ExperimentalWarning: The fs.promises API is experimental” ,可以按照以下方法进行操作:
打开项目中的tsconfig.json文件。
在compilerOptions下添加以下内容:
"compilerOptions": {
"lib": ["es2018", "dom"],
"esModuleInterop": true
}
这将添加"es2018"和"dom"到编译器选项中,并启用esModuleInterop。
polyfills.ts文件中添加以下代码:(window as any).global = window;
这将解决由于缺少全局变量而引发的警告。
tsconfig.app.json文件中,确保"compilerOptions"下的"target"设置为"es2015",并添加以下内容:"compilerOptions": {
"target": "es2015",
"esModuleInterop": true
}
这将确保代码在编译时与Angular 10兼容。
以上步骤完成后,重新编译您的Angular 10应用程序,并且该警告应该不再出现。