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

问题描述 投票:1回答:1

所以我已经用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.
angular command-line-interface
1个回答
0
投票

从/usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/package.json中删除“类型”:“模块”

© www.soinside.com 2019 - 2024. All rights reserved.