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

Issue: Can't build/run a basic standalone Angular app SSR (or not) #26318

Closed
1 task
tom-laplace opened this issue Nov 10, 2023 · 12 comments
Closed
1 task

Issue: Can't build/run a basic standalone Angular app SSR (or not) #26318

tom-laplace opened this issue Nov 10, 2023 · 12 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@tom-laplace
Copy link

Command

build, serve

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 can't build/run a basic project using Angular 17. Even just after initialization.

Minimal Reproduction

  • ng new crash-test --standalone --ssr OR ng new crash-test --standalone
  • npm i
  • npm run build OR npm run start

Exception or Error

src/app/app.component.ts:1:26:
      1 │ import { Component } from '@angular/core';
        ╵                           ~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/core" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

✘ [ERROR] Could not resolve "@angular/common"

    src/app/app.component.ts:2:29:
      2 │ import { CommonModule } from '@angular/common';
        ╵                              ~~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/common" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/common" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


✘ [ERROR] Could not resolve "@angular/router"

    src/app/app.component.ts:3:29:
      3 │ import { RouterOutlet } from '@angular/router';
        ╵                              ~~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/router" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/router" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


✘ [ERROR] Could not resolve "@angular/router"

    src/app/app.config.ts:1:30:
      1 │ import { provideRouter } from '@angular/router';
        ╵                               ~~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/router" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/router" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


✘ [ERROR] Could not resolve "@angular/common/http"

    src/app/app.config.ts:3:34:
      3 │ import { provideHttpClient } from '@angular/common/http';
        ╵                                   ~~~~~~~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/common" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/common/http" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


✘ [ERROR] Could not resolve "@angular/platform-browser"

    src/main.ts:1:37:
      1 │ import { bootstrapApplication } from '@angular/platform-browser';
        ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@angular/platform-browser" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "@angular/platform-browser" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


✘ [ERROR] Could not resolve "zone.js"

    angular:polyfills:angular:polyfills:1:7:
      1 │ import 'zone.js';
        ╵        ~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "zone.js" here because it's not listed as a dependency of this package:

    ../../../../.pnp.cjs:38:33:
      38 │           "packageDependencies": [\
         ╵                                  ~~

  You can mark the path "zone.js" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

Your Environment

Angular CLI: 17.0.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: linux x64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1700.0
@angular-devkit/core         17.0.0
@angular-devkit/schematics   17.0.0
@angular/cli                 17.0.0
@schematics/angular          17.0.0

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

I am a bit confused, are you using Yarn PNP or NPM? In the repro steps you mention npm i but the errors suggest that you are using Yarn PNP

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label Nov 10, 2023
@tom-laplace
Copy link
Author

I am a bit confused, are you using Yarn PNP or NPM? In the repro steps you mention npm i but the errors suggest that you are using Yarn PNP

Yup that confuse me too as I’m using NPM and not Yarn

@alan-agius4
Copy link
Collaborator

@tom-laplace, I am unable to replicate this using the steps provided. Based on the error, It does look like you might have some Yarn PNP config up in the file system.

@tom-laplace
Copy link
Author

@tom-laplace, I am unable to replicate this using the steps provided. Based on the error, It does look like you might have some Yarn PNP config up in the file system.

Just erased all the installation of Yarn on my machine, still don't work.

The strangiest is that I created a project yesterday, worked perfectly and I can still run it.

@Tony133
Copy link

Tony133 commented Nov 11, 2023

Hi all,
Today while I was testing the new version of Angular v17.x I also encountered a similar problem (see screenshot):

screen-error

checking the hidden files in the root in my computer I noticed that there was a pnp.cjs file which I believe is generated there when I installed packages globally, pnpm or libraries for the various projects I am working on, and deleting this file the angular application works correctly and no longer gives me any errors.

The angular application was created by cli, to create a new project.

If you need it, I'll attach the file I deleted, I'll rewrite it here, it's called pnp.cjs

Note: the pnp.cjs file is a hidden file , you should find it as .pnp.cjs

I hope I was helpful 🙂

@csisy

This comment was marked as off-topic.

@csisy-bt4w

This comment was marked as off-topic.

@alan-agius4
Copy link
Collaborator

Based on the comments above and the existence of a pnp.cjs file this is working as expected.

See: evanw/esbuild#3338 and evanw/esbuild#2495 (comment)

@csisy and @csisy-btw you issues are unrelated to this, so please open a new issue together with a minimal reproduction.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2023
@Truenotierra73
Copy link

Hi all, Today while I was testing the new version of Angular v17.x I also encountered a similar problem (see screenshot):

screen-error checking the hidden files in the root in my computer I noticed that there was a `pnp.cjs` file which I believe is generated there when I installed packages globally, pnpm or libraries for the various projects I am working on, and deleting this file the angular application works correctly and no longer gives me any errors.

The angular application was created by cli, to create a new project.

If you need it, I'll attach the file I deleted, I'll rewrite it here, it's called pnp.cjs

I hope I was helpful 🙂

It's correct. By deleting this file, the project is compiled again.

@kennethkeim
Copy link

Should this be picking up .pnp.cjs in the root of my computer as well? I removed it there and it's working now.

@alan-agius4
Copy link
Collaborator

Should this be picking up .pnp.cjs in the root of my computer as well? I removed it there and it's working now.

Yes, please see the above linked esbuild issues.

@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 Dec 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

7 participants