analogjs / analog

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

Issues with PNPM #361

Closed Anthony-Wratpor closed 6 months ago

Anthony-Wratpor commented 1 year ago

Please provide the environment you discovered this bug in.

Following the Getting started doc i created a new analog projectn on a windows 11 machine, with the angular-v16-prerelease variant and with tailwind enabled. image I did a pnpm install that installed thoses dependencies : image Then i did a pnpm run dev.

Which area/package is the issue in?

Don't know / Other

Description

At first it seems to work great : image

but on the second part of the script it fails with two errors:

Please provide the exception or error you saw

X [ERROR] [plugin angular-compiler] Cannot read properties of undefined (reading 'allowJs')

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:134:62:
      134 │                     const { affectedFiles, compilerOptions: { allowJs }, } = yield compilation.initialize(pluginOptions.tsconf...
          ╵                                                               ^

    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:134:63
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

  This error came from the "onStart" callback registered here:

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:114:22:
      114 │                 build.onStart(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
          ╵                       ~~~~~~~

    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:114:23
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)

X [ERROR] [plugin angular-compiler] Invalid plugin execution order

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:183:27:
      183 │                     assert.ok(fileEmitter, 'Invalid plugin execution order');
          ╵                            ^

    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:183:28
    at Generator.next (<anonymous>)
    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:114:16)
    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:181:38
    at requestCallbacks.on-load (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:1426:28)
    at handleRequest (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:727:19)
    at handleIncomingPacket (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:749:7)
    at Socket.readFromStdout (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:677:7)

  This error came from the "onLoad" callback registered here:

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:179:22:
      179 │                 build.onLoad({
          ╵                       ~~~~~~

    at C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:179:23
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Anthony\Desktop\Projets\analog\analog-project\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)

  The plugin "angular-compiler" was triggered by this import

    html:C:/Users/Anthony/Desktop/Projets/analog/analog-project/index.html:1:7:
      1 │ import "/src/main.ts"
        ╵        ~~~~~~~~~~~~~~

Build failed with 2 errors:
node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:134:62: ERROR: [plugin: angular-compiler] Cannot read properties of undefined (reading 'allowJs')
node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:183:27: ERROR: [plugin: angular-compiler] Invalid plugin execution order

Other information

I did not edit any files from the installation, if you need any more informations feel free to ask me anything.

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

hallowatcher commented 1 year ago

Having the same problem

D:\Projects>pnpm create analog
../.pnpm-store/v3/tmp/dlx-24924          |   +6 +
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: D:\.pnpm-store\v3
  Virtual store is at:             ../.pnpm-store/v3/tmp/dlx-24924/node_modules/.pnpm
../.pnpm-store/v3/tmp/dlx-24924 ../.pnpm-store/v3/tmp/dlx-24924          | Progress: resolved 6, reused 6, downloaded 0, added 6, done: » analog-project
√ Project name: ... testing-analog-js
√ Select a template: » Analog
√ Select a variant: » angular-v16-prerelease
√ Would you like to add Tailwind to your project? ... yes

Scaffolding project in D:\Projects\testing-analog-js...

Initializing git repository:

Done. Now run:

  cd testing-analog-js
  pnpm install
  pnpm run dev

D:\Projects>cd testing-analog-js

D:\Projects\testing-analog-js>pnpm i
 WARN  deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
 WARN  deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
 WARN  deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
 WARN  deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
 WARN  deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
 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
Packages: +1332
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: D:\.pnpm-store\v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 1324, reused 821, downloaded 430, added 1332, done
node_modules/.pnpm/@parcel+watcher@2.0.4/node_modules/@parcel/watcher: Running install script, done in 207ms
node_modules/.pnpm/esbuild@0.17.16/node_modules/esbuild: Running postinstall script, done in 352ms
node_modules/.pnpm/nx@15.7.0/node_modules/nx: Running postinstall script, done in 1.2s

dependencies:
+ @analogjs/content 0.2.0-beta.3
+ @analogjs/router 0.2.0-beta.3
+ @angular/animations 16.0.0-rc.0
+ @angular/common 16.0.0-rc.0
+ @angular/compiler 16.0.0-rc.0
+ @angular/core 16.0.0-rc.0
+ @angular/forms 16.0.0-rc.0
+ @angular/platform-browser 16.0.0-rc.0
+ @angular/platform-browser-dynamic 16.0.0-rc.0
+ @angular/platform-server 16.0.0-rc.0
+ @angular/router 16.0.0-rc.0
+ @nrwl/angular 15.7.0 (16.0.1 is available)
+ front-matter 4.0.2
+ marked 4.2.12 (4.3.0 is available)
+ prismjs 1.29.0
+ rxjs 7.5.6 (7.8.1 is available)
+ tslib 2.4.0 (2.5.0 is available)
+ zone.js 0.13.0

devDependencies:
+ @analogjs/platform 0.2.0-beta.3
+ @angular-devkit/build-angular 16.0.0-rc.0
+ @angular/cli 16.0.0-rc.0
+ @angular/compiler-cli 16.0.0-rc.0
+ @nrwl/vite 15.7.0 (16.0.1 is available)
+ autoprefixer 10.4.14
+ jsdom 20.0.0 (21.1.1 is available)
+ nx 15.7.0 (16.0.1 is available)
+ postcss 8.4.21 (8.4.23 is available)
+ tailwindcss 3.3.1 (3.3.2 is available)
+ typescript 5.0.2 (5.0.4 is available)
+ vite 4.0.3 (4.3.3 is available)
+ vitest 0.25.8 (0.30.1 is available)

 WARN  Issues with peer dependencies found
.
└─┬ @nrwl/vite 15.7.0
  └─┬ @nrwl/devkit 15.7.0
    └─┬ @phenomnomnominal/tsquery 4.1.1
      └── ✕ unmet peer typescript@"^3 || ^4": found 5.0.2

The integrity of 5409 files was checked. This might have caused installation to take longer.
Done in 31.4s

D:\Projects\testing-analog-js>pnpm run start

> testing-analog-js@0.0.0 start D:\Projects\testing-analog-js
> pnpm run dev

> testing-analog-js@0.0.0 dev D:\Projects\testing-analog-js
> ng serve

? Would you like to share pseudonymous usage data about this project with the Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
details and how to change this setting, see https://angular.io/analytics. No
Global setting: not set
Local setting: disabled
Effective status: disabled

The '@analogjs/platform' successfully started.
The server endpoints are accessible under the "/api" path.
  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
X [ERROR] [plugin angular-compiler] Cannot read properties of undefined (reading 'allowJs')

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:134:62:
      134 │ ...         const { affectedFiles, compilerOptions: { allowJs }, } = yield compilation.initialize(plugin...
          ╵                                                       ^

    at D:\Projects\testing-analog-js\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:134:63
    at Generator.next (<anonymous>)
    at fulfilled (D:\Projects\testing-analog-js\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

  This error came from the "onStart" callback registered here:

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:114:22:
      114 │                 build.onStart(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
          ╵                       ~~~~~~~

    at D:\Projects\testing-analog-js\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:114:23
    at Generator.next (<anonymous>)
    at fulfilled (D:\Projects\testing-analog-js\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)

X [ERROR] [plugin angular-compiler] Invalid plugin execution order

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:183:27:
      183 │                     assert.ok(fileEmitter, 'Invalid plugin execution order');
          ╵                            ^

    at D:\Projects\testing-analog-js\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:183:28
    at Generator.next (<anonymous>)
    at D:\Projects\testing-analog-js\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (D:\Projects\testing-analog-js\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:114:16)
    at D:\Projects\testing-analog-js\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:181:38
    at requestCallbacks.on-load (D:\Projects\testing-analog-js\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:1426:28)
    at handleRequest (D:\Projects\testing-analog-js\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:727:19)
    at handleIncomingPacket (D:\Projects\testing-analog-js\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:749:7)
    at Socket.readFromStdout (D:\Projects\testing-analog-js\node_modules\.pnpm\esbuild@0.16.17\node_modules\esbuild\lib\main.js:677:7)

  This error came from the "onLoad" callback registered here:

    node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:179:22:
      179 │                 build.onLoad({
          ╵                       ~~~~~~

    at D:\Projects\testing-analog-js\node_modules\.pnpm\@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0\node_modules\@analogjs\vite-plugin-angular\src\lib\compiler-plugin.js:179:23
    at Generator.next (<anonymous>)
    at fulfilled (D:\Projects\testing-analog-js\node_modules\.pnpm\tslib@2.4.0\node_modules\tslib\tslib.js:115:62)

  The plugin "angular-compiler" was triggered by this import

    html:D:/Projects/testing-analog-js/index.html:1:7:
      1 │ import "/src/main.ts"
        ╵        ~~~~~~~~~~~~~~

Build failed with 2 errors:
node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:134:62: ERROR: [plugin: angular-compiler] Cannot read properties of undefined (reading 'allowJs')
node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@16.0.0-rc.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:183:27: ERROR: [plugin: angular-compiler] Invalid plugin execution order
Anthony-Wratpor commented 1 year ago

I tried again to create a new application and this time i used npm instead of pnpm, and it worked, so the problem might be with pnpm

t-mish commented 1 year ago

I tried again to create a new application and this time i used npm instead of pnpm, and it worked, so the problem might be with pnpm

Agreed, tried the same with pnpm first then with npm. Pnpm's didn't succeed.

My running environment is: Macbook: M1, Pnpm: v8.3.1 Node: v18.16.0 Before this test I cleared Pnpm's cache

Project configuration:

Screenshot 2023-05-03 at 13 01 17

But my problem is different from mentioned above

failed to load config from /Users/tmish/WebstormProjects/analog-project-pnpm/vite.config.ts
Error: Cannot find module '@angular-devkit/build-angular/src/builders/browser-esbuild/angular/aot-compilation'
Require stack:
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/lib/angular-vite-plugin.js
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/index.js
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+platform@0.1.0-beta.22_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/platform/src/lib/platform-plugin.js
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+platform@0.1.0-beta.22_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/platform/src/index.js
- /Users/tmish/WebstormProjects/analog-project-pnpm/vite.config.ts
- /Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/vite@4.0.3_@types+node@18.16.3_less@3.12.2_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-0bae2027.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js:18:27)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at _require.extensions.<computed> [as .js] (file:///Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/vite@4.0.3_@types+node@18.16.3_less@3.12.2_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-0bae2027.js:62080:17)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/lib/compiler-plugin.js',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/lib/angular-vite-plugin.js',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+vite-plugin-angular@0.2.0-beta.3_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/vite-plugin-angular/src/index.js',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+platform@0.1.0-beta.22_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/platform/src/lib/platform-plugin.js',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/@analogjs+platform@0.1.0-beta.22_@angular-devkit+build-angular@15.0.0/node_modules/@analogjs/platform/src/index.js',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/vite.config.ts',
    '/Users/tmish/WebstormProjects/analog-project-pnpm/node_modules/.pnpm/vite@4.0.3_@types+node@18.16.3_less@3.12.2_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-0bae2027.js'
  ]
}
t-mish commented 1 year ago

After resolving of #344 when I create a new project with pnpm and Angular v15 I get following error when I execute "pnpm run dev"

An unhandled exception occurred: Package subpath './package.json' is not defined by "exports" in /Users/tmish/WebstormProjects/analog-new-project/node_modules/@nrwl/vite/package.json
See "/private/var/folders/xc/k1zpqxbs0313j2zvqngz_5p80000gn/T/ng-MGjmVe/angular-errors.log" for further details.
sugihartolim commented 1 year ago

Tried the getting started docs this weekend (via npm run dev) and the demo app is not even working (clicking button does nothing), with this showing up on the console:

caught SyntaxError: The requested module '/node_modules/.vite/deps/@angular_core.js?v=f9aba494' does not provide an export named 'assertInInjectionContext' (at analogjs-router.mjs?v=444d309e:1:161)

Is this an issue on my side? or is the getting started instruction outdated?

brandonroberts commented 1 year ago

Tried the getting started docs this weekend (via npm run dev) and the demo app is not even working (clicking button does nothing), with this showing up on the console:

caught SyntaxError: The requested module '/node_modules/.vite/deps/@angular_core.js?v=f9aba494' does not provide an export named 'assertInInjectionContext' (at analogjs-router.mjs?v=444d309e:1:161)

Is this an issue on my side? or is the getting started instruction outdated?

This was an issue when creating a new starter project with Angular v15. The issue has been resolved and will go out with the next release tomorrow

sugihartolim commented 1 year ago

Tried again tonight after a new update showed up. Still doesn't work, but different error message now.

[vite] connecting...
[vite] connected.

JIT compilation failed for injectable class PlatformLocation {
    historyGo(relativePosition) {
        throw new Error('Not implemented');
    }
}

Uncaught Error: The injectable 'PlatformLocation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

The injectable is part of a library that has been partially compiled.
However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.

Ideally, the library is processed using the Angular Linker to become fully AOT compiled.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at getCompilerFacade (core.mjs:3984:15)
    at Module.ɵɵngDeclareFactory (core.mjs:27346:22)
    at platform_location.ts:71:4
brandonroberts commented 1 year ago

@sugihartolim what version of packages are you on? What did you use to generate the project?

sugihartolim commented 1 year ago

I'm on Angular 15. Should i be using angular 16 instead?

using 'npm init analog' and 'npm create analog' resulted in "^0.2.0-beta.16", giving the errors i reported in the previous post. using 'npm init analog@latest' resulted in "^0.2.0-beta.17", giving the same errors on console.

On first compile, both versions also show this error message in a popup window:

Cannot read properties of undefined (reading 'getCurrentDirectory')
    at getRootDirs (file:///D:/PROJECTS/analog/node_modules/@angular/compiler-cli/bundles/chunk-ZCBRXUPO.js:78:20)
    at NgCompilerHost.wrap (file:///D:/PROJECTS/analog/node_modules/@angular/compiler-cli/bundles/chunk-M65TNV27.js:7460:22)
    at new NgtscProgram (file:///D:/PROJECTS/analog/node_modules/@angular/compiler-cli/bundles/chunk-M65TNV27.js:7538:32)
    at D:\PROJECTS\analog\node_modules\@analogjs\vite-plugin-angular\src\lib\angular-vite-plugin.js:350:36
    at Generator.next (<anonymous>)
    at D:\PROJECTS\analog\node_modules\tslib\tslib.js:167:75
    at new Promise (<anonymous>)
    at Object.__awaiter (D:\PROJECTS\analog\node_modules\tslib\tslib.js:163:16)
    at buildAndAnalyze (D:\PROJECTS\analog\node_modules\@analogjs\vite-plugin-angular\src\lib\angular-vite-plugin.js:348:24)
    at D:\PROJECTS\analog\node_modules\@analogjs\vite-plugin-angular\src\lib\angular-vite-plugin.js:115:31
Click outside or fix the code to dismiss.
You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
brandonroberts commented 1 year ago

You can these steps to get a working setup with pnpm.

To get initial setup

  1. Run the new project command pnpm create analog@latest analog-app
  2. cd analog-app
  3. Create an .npmrc in the root of the project with resolution-mode=highest
  4. Install the dependencies pnpm install
  5. Run the command to serve the app pnpm run dev

To fix the pnpm build command

  1. Install the destr package pnpm install destr --save-dev
  2. Run the command to build the app pnpm build

To fix the pnpm test command

  1. Install the @analogjs/vite-plugin-angular package pnpm install @analogjs/vite-plugin-angular --save-dev
  2. Run the command to test the app pnpm test

We'll look at what we can do make this more seamless for pnpm

AdditionAddict commented 11 months ago

Getting error with pnpm, same steps with npm works fine:

An unhandled exception occurred: Package "@analogjs/platform" has no builders defined.
See "/private/var/folders/7h/j6zg943x2zz51t9j56sr6qn80000gn/T/ng-eBE4Mf/angular-errors.log" for further details.
 ELIFECYCLE  Command failed.

   Logs:

 andrew@Andrews-MacBook-Air repos % pnpm create analog
.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 1, reused 0, downl.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 3, reused 2, downl.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 4, reused 2, downl.../Library/pnpm/store/v3/tmp/dlx-10461  |   +6 +
.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 4, reused 2, downlPackages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/andrew/Library/pnpm/store/v3
  Virtual store is at:             ../../Library/pnpm/store/v3/tmp/dlx-10461/node_modules/.pnpm
.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 4, reused 2, downl.../Library/pnpm/store/v3/tmp/dlx-10461  | Progress: resolved 6, reused 5, downloaded 1, added 6, done
✔ Project name: … example-app
✔ Select a template: › Analog
✔ Select a variant: › angular-v16
✔ Would you like to add Tailwind to your project? … yes

Scaffolding project in /Users/andrew/dev/repos/example-app...

Initializing git repository:

Done. Now run:

  cd example-app
  pnpm install
  pnpm run dev

andrew@Andrews-MacBook-Air repos %  cd example-app
andrew@Andrews-MacBook-Air example-app % pnpm i
 WARN  deprecated @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
 WARN  deprecated @wessberg/ts-evaluator@0.0.27: this package has been renamed to ts-evaluator. Please install ts-evaluator instead
 WARN  deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
 WARN  deprecated @babel/plugin-proposal-unicode-property-regex@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead.
 WARN  deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
 WARN  deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
Packages: +1575
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/andrew/Library/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 1575, reused 1427, downloaded 56, added 1575, done
node_modules/.pnpm/esbuild@0.19.5/node_modules/esbuild: Running postinstall scrinode_modules/.pnpm/esbuild@0.19.5/node_modules/esbuild: Running postinstall script, done in 647msm/nx@16.8.1/node_modules/nx: Running postinstall script, done inode_modules/.pnpm/nx@17.0.0/node_modules/nx: Running postinstall script, done in 803ms

dependencies:
+ @analogjs/content 0.2.0 (0.2.11 is available)
+ @analogjs/router 0.2.0 (0.2.2 is available)
+ @angular/animations 16.2.0 (16.2.11 is available)
+ @angular/common 16.2.0 (16.2.11 is available)
+ @angular/compiler 16.2.0 (16.2.11 is available)
+ @angular/core 16.2.0 (16.2.11 is available)
+ @angular/forms 16.2.0 (16.2.11 is available)
+ @angular/platform-browser 16.2.0 (16.2.11 is available)
+ @angular/platform-browser-dynamic 16.2.0 (16.2.11 is available)
+ @angular/platform-server 16.2.0 (16.2.8 is available)
+ @angular/router 16.2.0 (16.2.11 is available)
+ @nx/angular 17.0.0 (17.0.2 is available)
+ front-matter 4.0.2
+ marked 5.0.2 (5.1.1 is available)
+ marked-gfm-heading-id 3.1.0
+ marked-highlight 2.0.1
+ mermaid 10.2.4 (10.3.1 is available)
+ prismjs 1.29.0
+ rxjs 7.5.6 (7.8.1 is available)
+ tslib 2.4.0 (2.6.2 is available)
+ zone.js 0.13.0 (0.14.1 is available)

devDependencies:
+ @analogjs/platform 0.2.0 (0.2.2 is available)
+ @angular-devkit/build-angular 16.2.0 (16.2.9 is available)
+ @angular/cli 16.2.0 (16.2.9 is available)
+ @angular/compiler-cli 16.2.0 (16.2.11 is available)
+ @nx/vite 16.8.1
+ autoprefixer 10.4.14 (10.4.16 is available)
+ jsdom 22.1.0
+ nx 17.0.0 (17.0.2 is available)
+ postcss 8.4.21 (8.4.31 is available)
+ tailwindcss 3.3.1 (3.3.3 is available)
+ typescript 5.0.2 (5.2.2 is available)
+ vite 4.4.8 (4.5.0 is available)
+ vitest 0.32.0 (0.34.6 is available)

The integrity of 3304 files was checked. This might have caused installation to take longer.
Done in 30.3s
andrew@Andrews-MacBook-Air example-app % pnpm dev

> example-app@0.0.0 dev /Users/andrew/dev/repos/example-app
> ng serve
brandonroberts commented 11 months ago

The builders weren't introduced until 0.2.15. pnpm is very particular about picking lower versions, so try bumping up the @analog packages to 0.2.18 and reinstall

brandonroberts commented 6 months ago

pnpm should work out of the box now with Analog 1.0