'Stackblitz Angular 13 project does not work locally

i'm trying to download and run a simply angular 13 progect example from Stackblitz to my local pc. Download ok, npm install ok. ng serve -o returns this message:

Your global Angular CLI version (13.2.5) is greater than your local version (11.0.7). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
An unhandled exception occurred: Must use import to load ES Module: C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@angular\compiler\fesm2015\compiler.mjs
See "C:\Users\F53E9~1.DIG\AppData\Local\Temp\ng-vlKUiI\angular-errors.log" for further details.

Here log:

[error] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@angular\compiler\fesm2015\compiler.mjs
    at Module.load (internal/modules/cjs/loader.js:926:11)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@angular\compiler-cli\index.js:22:22
    at C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@angular\compiler-cli\index.js:3:17
    at Object.<anonymous> (C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@angular\compiler-cli\index.js:9:3)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\f.digiuseppe\Downloads\angular-ivy-dobvru\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:13:24)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

Node version: v14.16.1 npm version: 6.14.12

Anyone can help me?

Thanks



Solution 1:[1]

I think you may check thing

  1. Make sure your package.json includes a line for "type": "module". Without this line, Node.js assumes you want to use CommonJS modules rather than ESM.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Piyush Kachhadiya