纯属个人开发过程遇到的问题,可能与你遇到的问题相似,在此分享一下,有问题欢迎提出,希望也能帮助到你们。
首先遇到标题类似问题,
一般都是当前使用依赖的版本过高导致,请将对应的依赖降低版本。
1.先卸载当前依赖 npm uninstall xxx,(取决于问题提示说那个插件有问题)
2.然后安装指定版本的依赖 npm i xxx@versionNum --save
这是我在进行gulp自动化构建时出现的具体问题(错误提示)
Error [ERR_REQUIRE_ESM]: require() of ES Module E:\C4-program\c4-advanced-01-foundation\c_auth\node_modules\del\index.js from E:\C4-program\c4-advanced-01-foundation\c_auth\gulpfile.js not supported.
Instead change the require of index.js in E:\C4-program\c4-advanced-01-foundation\c_auth\gulpfile.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (E:\C4-program\c4-advanced-01-foundation\c_auth\gulpfile.js:3:13)
at async Promise.all (index 0) {
code: 'ERR_REQUIRE_ESM'
}
从这个错误提示不难看出:应该是require() of ES Module问题,并且还是del插件的问题,导致require不能正常使用。
我原本自动安装的del版本时7.0.0的,试着换了一下6.0.0版本结果成功运行了。
大家也可以自己试试更低版本的,但不要太低,我还没尝试过。
欢迎大家批评指正~