简体   繁体   中英

angular cli must use import to load ES module

So i have installed angular with npm install -g @angular/cli and updated npm, but if i try to run ng in terminal i get this output. I dont want to edit these files before im sure im not screwing them up

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.

removed "type": "module" from /usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/package.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM