'Angular serve fails with esm
I just created a fresh Angular universal app using Angular cli. it just works fine.
however, when I just add "type": "module" to package.json and serve again (with or without rebuilding the app again) it fails with the error Strict mode code may not include a with statement
reproduction steps
1- create a new Angular universal app ng new example && cd example && ng add @nguniversal/express-engine
2- run npm start -> npm run build:ssr && npm run serve:ssr (suceesed)
3- add "type": "module" and run npm run serve:ssr or npm start again (faild with Strict mode code may not include a with statement)
4- remove "type": "module" and run npm run serve:ssr without rebuilding the app (successed)
trials
- remove
ServerModulefrom imports[] im app/app.server.module.ts - remove
export { renderModule } from '@angular/platform-server';in app/main.server.ts - run
npm startto rebuild the app (failed with the same error)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
