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

Ng serve fails with Yarn and the -ng4 flag #4787

Closed
Ionaru opened this issue Feb 17, 2017 · 10 comments
Closed

Ng serve fails with Yarn and the -ng4 flag #4787

Ionaru opened this issue Feb 17, 2017 · 10 comments

Comments

@Ionaru
Copy link

Ionaru commented Feb 17, 2017

OS?

Lubuntu 16.10

Versions.

@angular/cli: 1.0.0-beta.32.3
node: 7.5.0
os: linux x64

Repro steps. (On a clean VM)

sudo yarn global add @angular/cli
ng set --global packageManager=yarn
ng new MyYarnApp -ng4
cd MyYarnApp
ng serve or ng build

or

sudo yarn global add @angular/cli
ng new MyYarnApp -ng4 --skip-install
cd MyYarnApp
yarn
ng serve or ng build

The log given by the failure.

** NG Live Development Server is running on http://localhost:4200. **
Hash: 431dce9b2028dcad96e7                                                               
Time: 7586ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 155 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 3.72 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.1 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.76 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in Could not resolve module @angular/core/src/di/opaque_token
webpack: Failed to compile.

Mention any other details that might be useful.

This seems to be a combination of installing packages with Yarn, and using Angular 4

@Ionaru Ionaru changed the title Ng serve fails with the Yarn and ng4 combinationng serve Ng serve fails with Yarn and the -ng4 flag Feb 17, 2017
@Meligy
Copy link
Contributor

Meligy commented Feb 17, 2017

This is a duplicate of #4611

Look at #4611 (comment) or #4781 for a workaround.

@Ionaru
Copy link
Author

Ionaru commented Feb 17, 2017

I can confirm that changing the Angular versions in the package.json works.
>=4.0.0-beta <5.0.0 changed to >=next <5.0.0

Edit: This installs Angular 2 instead of 4

@Ionaru Ionaru closed this as completed Feb 17, 2017
@Meligy
Copy link
Contributor

Meligy commented Feb 17, 2017

Run ng version to be sure again.
It turned out it actually installed ng2 not ng4 :(

@Meligy
Copy link
Contributor

Meligy commented Feb 17, 2017

But then again maybe following #4611 (comment) literally works. I'll be trying this later.

@jwuliger
Copy link

@Ionaru Brilliant! This worked for me. Thanks so much!

@jwuliger
Copy link

Well I spoke to soon. Meh. @Meligy you are correct. The above change to package.json results in a NG2 install.

@Ionaru
Copy link
Author

Ionaru commented Feb 18, 2017

@Meligy you are correct, it does use Angular 2 with that change. My bad.

I don't think using npm link is the right solution for this issue, however it can be a temporary workaround.

@Ionaru Ionaru reopened this Feb 18, 2017
@victornoel
Copy link

For those interested, I posted a clean workaround for this problem in #4611 (comment).

@filipesilva
Copy link
Contributor

Dupe of #4611

@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 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants