所以我已经用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中删除“类型”:“模块”