question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building Angular: Yarn link to project

See original GitHub issue

πŸ“š Docs or angular.io bug report

Description

When working on a codebase most developers appreciate being able to test and experience the changes they commit. In order to ease new Angular contributors it would be most helpful to have some documentation how to use a local Angular build as a dependecy in a test project.

I think it would be great if someone more experienced could add some exemplaric steps to the official contriubuting guide.

What’s the affected URL?**

DEVELOPER.md#building / #running tests locally

Reproduction Steps**

So far I’ve

  • build Angular via angular/scripts/build-packages.sh
  • run yarn link inside angular/dist/package-dist/router to create a symlink for @angular/router
  • and tried using it in my test project via yarn link @angular/router

After many different approaches (for example linking the contents of angular/dist/bin/packages/router) it never worked, because the routing module itself or other dependencies like @angular/common/core/platform-browser/… could not be found.

Expected vs Actual Behavior**

Expected to have more detailed instructions how to link the contents of the dist/packages-dist folder to a test project (similiar to the subprojects in angular/integration).

πŸ“·Screenshot

angular-link-error

πŸ”₯ Exception or Error


ERROR in ../angular/dist/router/fesm5/router.js
Module not found: Error: Can't resolve '@angular/common' in 'C:\Users\grilborzer\Code\angular\dist\router\fesm5'
ERROR in ../angular/dist/router/fesm5/router.js
Module not found: Error: Can't resolve '@angular/core' in 'C:\Users\grilborzer\Code\angular\dist\router\fesm5'
ERROR in ../angular/dist/router/fesm5/router.js
Module not found: Error: Can't resolve '@angular/platform-browser' in 'C:\Users\grilborzer\Code\angular\dist\router\fesm5'

🌍 Your Environment

Windows 10 [Version 10.0.16299.1268] Enterprise v. 1709 Yarn 1.16.0 Node 10.9.0

Anything else relevant?

I tried mentioned steps on Windows and on an Ubuntu Subsystem.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
gkalpakcommented, Oct 30, 2019

I haven’t tried yarn link with the built Angular packages. (I suspect it might not work anyway.) What works for me for testing the built packages against a local project is changing the project’s package.json to point to the local Angular packages.

E.g. if I have built the packages in /angular/dist/packages-dist/ and I want to test them on a project at /my-projects/test-project/, I would update /my-projects/test-project/package.json as follows:

 {
   ...
   "dependencies": {
-    "@angular/common": "9.0.0",
+    "@angular/common": "file:../../angular/dist/packages-dist/common",
-    "@angular/core": "9.0.0",
+    "@angular/core": "file:../../angular/dist/packages-dist/core",
     ...
   }
 }

After that, running npm install or yarn install will install the locally built Angular packages.

LMK if this is enough to unblock you, @s-gbz.

BTW, since recently, it is also possible to grab the packages from a PR’s build artifacts.

3reactions
s-gbzcommented, Oct 30, 2019

Looks like it worked!! (I think I had tried sth. similiar, too bad it didn’t work back then) Thank you so much for the support @gkalpak and generous offer @kapunahelewong ❀️

Read more comments on GitHub >

github_iconTop Results From Across the Web

yarn link
Use yarn link [package] to link another package that you'd like to test into your current project. To follow the above example, in...
Read more >
Unsolving the mysteries of yarn/npm link for libraries ...
It's pretty simple, you should just build your library locally, then you run yarn link in the directory you build it, by doing...
Read more >
angular-library-seed documentation - Trekhleb
There are several ways to go here: Use your real library-consumer project and link your library to it via yarn link command (see...
Read more >
Can't link my library Angular in another library Angular
However, when I create a symlink of lib1 and import it into lib2 and lib3 with the command "npm link lib1", I get...
Read more >
Creating libraries - Angular
Integrating with the CLI using code-generation schematicslink Β· Include an installation schematic so that ng add can add your library to a project...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found