-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
-
Using the ready-made https://angular.io/generated/zips/universal/universal.zip from https://angular.io/guide/universal.
-
Edited
server.tsor the TypeScript would whine (TS4111) and refuse to run.- const port = process.env.PORT || 4000; + const port = process.env['PORT'] || 4000;
-
I added the following at the very beginning of the
server.ts:+ console.log("NODEJS VERSION:", process.version); + console.log("=====1====="); + import * as fs from 'fs'; + console.log("2nd-level API fs.appendFile:", fs.appendFile); // a second-level API (fs.xxx) + console.log("2nd-level API fs.realpath:", fs.realpath); + console.log("3rd-level API fs.realpath.native:", fs.realpath.native); // a third-level API (fs.xxx.yyy) = import 'zone.js/node'; + console.log("=====2====="); + console.log("2nd-level API fs.appendFile:", fs.appendFile); // a second-level API (fs.xxx) + console.log("2nd-level API fs.realpath:", fs.realpath); + console.log("3rd-level API fs.realpath.native:", fs.realpath.native); // a third-level API (fs.xxx.yyy) = import { ngExpressEngine } from '@nguniversal/express-engine';
-
npm installfollowed bynpm run dev:ssrcommand. -
It seems like the
import 'zone.js/node';did something to thefs.
fs.realpath.nativebecomeundefinedfrom the logs. -
It does seem like zone.js/node did not factor in
fsthird-level functions. From the fs API documentation, most are second-level functions (i.e.fs.xxx). But there are 2 exceptions since NodeJS 9.2.0 that are in third-level (i.e.fs.xxx.yyy), which arefs.realpath.nativeandfs.realpathSync.native. So when the package did some wrapping around, the third-level functions broke.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
`fs.realpath.native` is `undefined`
`fs.realpathSync.native` is `undefined`
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 13.3.1
Node: 14.19.1
Package Manager: npm 6.14.16
OS: win32 x64
Angular: 13.3.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1303.1 (cli-only)
@angular-devkit/build-angular 13.3.1
@angular-devkit/core 13.3.1 (cli-only)
@angular-devkit/schematics 13.3.1 (cli-only)
@nguniversal/builders 13.1.0
@nguniversal/express-engine 13.1.0
@schematics/angular 13.3.1 (cli-only)
rxjs 7.4.0
typescript 4.5.5
Anything else?
Fixed by PR #45552