Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building SSR project using NodeJS v18.19.0 fails with obscure error message An unexpected error occurred: [object Object] #26648

Closed
1 task
awaragi opened this issue Dec 12, 2023 · 1 comment · Fixed by #26650

Comments

@awaragi
Copy link

awaragi commented Dec 12, 2023

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I initially found out about this bug while successfully building locally my SSR project using v18.14.2 and when building in github workflow ubuntu runner using v18.x which defaulted to v18.19.0. When I switched locally to the same version v18.19.0 I got the same error. Switching the github workflow to use v18.14.2 was a valid workaround. I am reporting this issue in case there is a hidden issue that Node v18.19.0 unhid.

I tried it with a vanilla project and the error is easily replicated. Here are the steps to replicate:

  • nvm install v18.19.0
  • ng new --ssr (default CSS)
  • npm run build

Here is the log of my local execution with both v18.14.2 and v18.19.0 showing that the build works in one and not in the other.

 developer  ~  Develop  Projects  npx @angular/cli new --ssr
? What name would you like to use for the new workspace and initial project? test-node
? Which stylesheet format would you like to use? CSS
CREATE test-node/README.md (1062 bytes)
CREATE test-node/.editorconfig (274 bytes)
CREATE test-node/.gitignore (548 bytes)
CREATE test-node/angular.json (2753 bytes)
CREATE test-node/package.json (1272 bytes)
CREATE test-node/tsconfig.json (903 bytes)
CREATE test-node/tsconfig.app.json (324 bytes)
CREATE test-node/tsconfig.spec.json (273 bytes)
CREATE test-node/server.ts (1703 bytes)
CREATE test-node/.vscode/extensions.json (130 bytes)
CREATE test-node/.vscode/launch.json (470 bytes)
CREATE test-node/.vscode/tasks.json (938 bytes)
CREATE test-node/src/main.ts (250 bytes)
CREATE test-node/src/favicon.ico (15086 bytes)
CREATE test-node/src/index.html (294 bytes)
CREATE test-node/src/styles.css (80 bytes)
CREATE test-node/src/main.server.ts (264 bytes)
CREATE test-node/src/app/app.component.css (0 bytes)
CREATE test-node/src/app/app.component.html (20884 bytes)
CREATE test-node/src/app/app.component.spec.ts (925 bytes)
CREATE test-node/src/app/app.component.ts (367 bytes)
CREATE test-node/src/app/app.config.ts (321 bytes)
CREATE test-node/src/app/app.routes.ts (77 bytes)
CREATE test-node/src/app/app.config.server.ts (350 bytes)
CREATE test-node/src/assets/.gitkeep (0 bytes)
✔ Packages installed successfully.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m
Successfully initialized git.
✔ Packages installed successfully.
 developer  ~  Develop  Projects  cd test-node/
 developer   master  ~  Develop  Projects  test-node  node -v
v18.19.0
 developer   master  ~  Develop  Projects  test-node  npm run build

test-node@0.0.0 build
ng build

An unexpected error occurred: [object Object]

 developer   master  ~  Develop  Projects  test-node  1  nvm use v18.14.2
Now using node v18.14.2 (npm v9.6.0)
 developer   master  ~  Develop  Projects  test-node  node -v
v18.14.2
 developer   master  ~  Develop  Projects  test-node  npm run build

test-node@0.0.0 build
ng build

Prerendered 1 static route.

Initial Chunk Files | Names | Raw Size | Estimated Transfer Size
main-SS6UDOSF.js | main | 204.02 kB | 56.57 kB
polyfills-LZBJRJJE.js | polyfills | 32.69 kB | 10.59 kB
styles-5INURTSO.css | styles | 0 bytes | 0 bytes

                  | Initial Total | 236.72 kB |                67.16 kB

Application bundle generation complete. [15.972 seconds]

 developer   master  ~  Develop  Projects  test-node  1  npx ng version

 _                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|

/ △ \ | '_ \ / | | | | |/ _ | '__| | | | | | |
/ ___ | | | | (
| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/

Angular CLI: 17.0.6
Node: 18.14.2
Package Manager: npm 9.6.0
OS: linux x64

Angular: 17.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package Version

@angular-devkit/architect 0.1700.6
@angular-devkit/build-angular 17.0.6
@angular-devkit/core 17.0.6
@angular-devkit/schematics 17.0.6
@schematics/angular 17.0.6
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2

the generated package.json is untouched:

{
"name": "test-node",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"serve:ssr:test-node": "node dist/test-node/server/server.mjs"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.0.0",
"@angular/common": "^17.0.0",
"@angular/compiler": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/forms": "^17.0.0",
"@angular/platform-browser": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular/platform-server": "^17.0.0",
"@angular/router": "^17.0.0",
"@angular/ssr": "^17.0.6",
"express": "^4.18.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.6",
"@angular/cli": "^17.0.6",
"@angular/compiler-cli": "^17.0.0",
"@types/express": "^4.17.17",
"@types/jasmine": "~5.1.0",
"@types/node": "^18.18.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.2.2"
}
}

image

Minimal Reproduction

  • nvm install v18.19.0
  • ng new --ssr (default CSS)
  • npm run build

Exception or Error

An unexpected error occurred: [object Object]

Your Environment

NodeJS v18.19.0 (locally and on github ubuntu runner)

Anything else relevant?

No response

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 12, 2023
…r occurred

In some cases, Node.js expection would only contain an error code, example `ERR_UNSUPPORTED_ESM_URL_SCHEME`. This caused `An unexpected error occurred: [object Object]` to be logged in the console.

Closes angular#26648
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 12, 2023
…de.js 18.19.0

In Node.js 18.19 ESM loaders works the same way as Node.js 20.9+

Closes angular#26648
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 12, 2023
…de.js 18.19.0

In Node.js 18.19 ESM loaders works the same way as Node.js 20.9+

Closes angular#26648
alan-agius4 added a commit that referenced this issue Dec 12, 2023
…de.js 18.19.0

In Node.js 18.19 ESM loaders works the same way as Node.js 20.9+

Closes #26648
alan-agius4 added a commit that referenced this issue Dec 12, 2023
…de.js 18.19.0

In Node.js 18.19 ESM loaders works the same way as Node.js 20.9+

Closes #26648

(cherry picked from commit 7a50df5)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.