gpt4 book ai didi

angular cli 必须使用 import 来加载 ES 模块

转载 作者:行者123 更新时间:2023-12-05 07:09:52 26 4
gpt4 key购买 nike

所以我已经使用 npm install -g @angular/cli 安装了 angular 并更新了 npm,但是如果我尝试在终端中运行 ng,我会得到这个输出。在确定我没有搞砸之前,我不想编辑这些文件

Unknown error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/index.js 
require() of ES modules is not supported.
require() of /usr/local/lib/node_modules/@angular/cli/node_modules/is promise/index.js from /usr/local/lib/node_modules/@angular/cli/node_modules/run-async/index.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 /usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/package.json.

最佳答案

从/usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/package.json 中删除了 "type": "module"

关于angular cli 必须使用 import 来加载 ES 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61428143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com