analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

[vite] Error when evaluating SSR module #321

Closed otonielguajardo closed 1 year ago

otonielguajardo commented 1 year ago

Please provide the environment you discovered this bug in.

Node: v18.11.0 OS: macOS Ventura 13.0.1 Chip: Apple M1

Which area/package is the issue in?

create-analog

Description

Installed fresh proyect of analog using npm init analog

Got error when opening http://localhost:5173/

Please provide the exception or error you saw

oguajardo@Otoniels-MacBook-Air Projects % npm init analog
✔ Project name: … test
✔ Select a template: › Analog
✔ Select a variant: › angular-v15

Scaffolding project in /Users/oguajardo/Projects/test...

Initializing git repository:

Done. Now run:

  cd test
  npm install
  npm run dev

oguajardo@Otoniels-MacBook-Air Projects % cd test/
oguajardo@Otoniels-MacBook-Air test % npm i
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead

added 1614 packages, and audited 1615 packages in 1m

134 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
oguajardo@Otoniels-MacBook-Air test % npm run dev

> test@0.0.0 dev
> ng serve

The '@analogjs/platform' successfully started.
The server endpoints are accessible under the "/api" path.
  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
10:46:31 PM [vite] Error when evaluating SSR module /node_modules/@angular/core/fesm2015/core.mjs: failed to import "rxjs"

10:46:31 PM [vite] Error when evaluating SSR module ~analog/entry-server:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

TypeError: Method Promise.prototype.then called on incompatible receiver [object Object]
    at ZoneAwarePromise.then (<anonymous>)
    at node:internal/per_context/primordials:440:35
    at new Promise (<anonymous>)
    at new SafePromise (node:internal/per_context/primordials:408:29)
    at node:internal/per_context/primordials:440:9
    at Array.map (<anonymous>)
    at arrayToSafePromiseIterable (node:internal/per_context/primordials:437:5)
    at node:internal/per_context/primordials:453:21
    at new Promise (<anonymous>)
    at primordials.SafePromiseAll (node:internal/per_context/primordials:452:3)

Node.js v18.11.0
oguajardo@Otoniels-MacBook-Air test % 

Other information

About 3 weeks ago, I initialized another analog proyect and worked flawlessly

This are the dependencies on the package-lock of that proyect,

 "dependencies": {
    "@analogjs/content": "^0.1.8",
    "@analogjs/router": "^0.1.0-alpha.8",
    "@angular/animations": "^15.0.0",
    "@angular/common": "^15.0.0",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/platform-server": "^15.0.0",
    "@angular/router": "^15.0.0",
    "@nrwl/angular": "^15.7.0",
    "front-matter": "^4.0.2",
    "marked": "^4.2.12",
    "prismjs": "^1.29.0",
    "rxjs": "~7.5.6",
    "tslib": "^2.4.0",
    "xp.css": "^0.2.6",
    "zone.js": "~0.11.8"
  },
  "devDependencies": {
    "@analogjs/platform": "^0.1.0-beta.18",
    "@angular-devkit/build-angular": "^15.0.0",
    "@angular/cli": "~15.0.0",
    "@angular/compiler-cli": "^15.0.0",
    "@nrwl/vite": "^15.7.0",
    "jsdom": "^20.0.0",
    "nx": "^15.7.0",
    "typescript": "~4.8.4",
    "vite": "^4.0.3",
    "vitest": "^0.25.8"
  },
  "engines": {
    "node": ">=16.0.0"
  }

And this is the new project package-lock, I noted in the new proyect it uses "latest" instead of an specific version, genuinely don't know if this has something to do

"dependencies": {
        "@analogjs/router": "latest",
        "@angular/animations": "^15.0.0",
        "@angular/common": "^15.0.0",
        "@angular/compiler": "^15.0.0",
        "@angular/core": "^15.0.0",
        "@angular/forms": "^15.0.0",
        "@angular/platform-browser": "^15.0.0",
        "@angular/platform-browser-dynamic": "^15.0.0",
        "@angular/platform-server": "^15.0.0",
        "@angular/router": "^15.0.0",
        "@nrwl/angular": "^15.7.0",
        "rxjs": "~7.5.6",
        "tslib": "^2.4.0",
        "zone.js": "~0.11.8"
      },
      "devDependencies": {
        "@analogjs/platform": "latest",
        "@angular-devkit/build-angular": "^15.0.0",
        "@angular/cli": "~15.0.0",
        "@angular/compiler-cli": "^15.0.0",
        "@nrwl/vite": "^15.7.0",
        "jsdom": "^20.0.0",
        "nx": "^15.7.0",
        "typescript": "~4.8.4",
        "vite": "^4.0.3",
        "vitest": "^0.25.8"
      },

I would be willing to submit a PR to fix this issue

brandonroberts commented 1 year ago

Duplicate of #203

This was a bug that has since been fixed in Angular. Try Node v18 13.0

https://github.com/analogjs/analog/issues/203#issuecomment-1399145967

otonielguajardo commented 1 year ago

Thanks @brandonroberts !