You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI Webpack does not work with linked local packages #2154
OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Linux CentOs 7
Versions. Please run ng --version. If there's nothing outputted, please run
in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.14
node: 6.2.2
os: linux x64
Repro steps. Was this an app that wasn't created using the CLI? What change did you
do on your code? etc.
This app was created using the CLI Beta 10 then updated following this guide
The log given by the failure. Normally this include a stack trace and some
more information.
I have a local Angular 2 library Package that I link (npm link mypackage) during development of this library. I have been working on this package in this manner for 6 months with no issues. Now that I am trying to upgrade to the CLI webpack version it no longer works
I have the package referenced in the dependencies section of my web app package.json file. I can see the sym link in my projects node_modules directory but it's like it does not exist when the app runs.
Another issue is that I have some css files inside this package but when I reference them in the angular-cli they are not loaded when the app loads.
It sounds to me like this must be a problem specific to the project type. I ran this a similar scenario the other day. I was having problems figuring out how to use a require.js lib because brocoli kept through errors as it wasn't a typescript project dispite the fact i had updated my type definitions and could build with the typescript compiler directly, so i thought i would try the webpack branch and that fixed the issue. Then i had the situation where i wanted to make changes to the require.js app so i also had to use an npm link to debug it all together. I didn't have any issues with it.
I went ahead and published my library package to our npm repo and installed it from there and it works as expected. The problems only exist when the library package is linked locally.
Agree, having same problem. I have other reusable components installed via npm link which are available from parent folder, but each time I need to run npm install for them, which is not really proper way, so I've tried npm link, but no luck.
Not sure how to escalate this or at least get someone from the CLI team to look at it but if it can't be addressed soon I'll have to move my current and future projects to a Gulp tooling workflow. We do a lot of development inside linked packages, a fair amount of our core functions are shared in npm packages. This issue is blocking progress for my team.
Solution (If you want to develop and build lib through the hosting app. This method will build the library with the methods and configuration of your app. Production releases can behave differently)
in the lib's package.json in the peerDependencies (this is for using the built library) and devDependencies (yes twice :), this is for building library separately, not through hosting app ) add all mutual (lib vs. host) dependencies (like all @angular, angular material, etc)
in the host's tsconfig.json (some are suggesting tsconfig.app.json, but it should work for tests as well ?) direct TS compiler to your local (host) dependencies of the mutual dependencies
Activity
rburnham52 commentedon Sep 16, 2016
It sounds to me like this must be a problem specific to the project type. I ran this a similar scenario the other day. I was having problems figuring out how to use a require.js lib because brocoli kept through errors as it wasn't a typescript project dispite the fact i had updated my type definitions and could build with the typescript compiler directly, so i thought i would try the webpack branch and that fixed the issue. Then i had the situation where i wanted to make changes to the require.js app so i also had to use an npm link to debug it all together. I didn't have any issues with it.
jbeckton commentedon Sep 16, 2016
I went ahead and published my library package to our npm repo and installed it from there and it works as expected. The problems only exist when the library package is linked locally.
serhiisol commentedon Sep 19, 2016
Agree, having same problem. I have other reusable components installed via
npm linkwhich are available from parent folder, but each time I need to runnpm installfor them, which is not really proper way, so I've triednpm link, but no luck.Any solutions so far?
PS. There's the link for workaround http://webpack.github.io/docs/troubleshooting.html#npm-linked-modules-doesn-t-find-their-dependencies, but webpack configuration isn't available for us to modify :(
jahller commentedon Sep 19, 2016
npm linkis also the proposed way to handle npm module development. what is the proposed way when using angular-cli, ifnpm linkis not working?jbeckton commentedon Sep 19, 2016
Not sure how to escalate this or at least get someone from the CLI team to look at it but if it can't be addressed soon I'll have to move my current and future projects to a Gulp tooling workflow. We do a lot of development inside linked packages, a fair amount of our core functions are shared in npm packages. This issue is blocking progress for my team.
filipesilva commentedon Sep 22, 2016
Dupe of #1875
mprinc commentedon Nov 9, 2017
Here is an explanation how to do it properly: https://github.com/angular/angular-cli/wiki/stories-linked-library
And here it is more elaborated:
Solution (If you want to develop and build lib through the hosting app. This method will build the library with the methods and configuration of your app. Production releases can behave differently)
package.jsonin thepeerDependencies(this is for using the built library) anddevDependencies(yes twice :), this is for building library separately, not through hosting app ) add all mutual (lib vs. host) dependencies (like all @angular, angular material, etc)tsconfig.json(some are suggestingtsconfig.app.json, but it should work for tests as well ?) direct TS compiler to your local (host) dependencies of the mutual dependencies{ ... "compilerOptions": { ... "baseUrl": "./", "note1": "these paths are relative to `baseUrl` path.", "paths": { "@angular/*": [ "node_modules/@angular/*" ] } ... } ... }.angular-cli.jsonadd:{ ... "defaults": { "build": { "preserveSymlinks": true } } ... }in this way you should be fine building lib in many scenarios
rudzikdawid commentedon Nov 26, 2017
i have similar problem with
@angular/cli 1.4.9here https://github.com/swiety85/angular2gridster/tree/137-demo-src-app-gridsterdir structure:
reproduce steps:
after that in
demo/node_moduleswe have linkedangular2gridsterpackage but with library'snode_moduleswhich unfortunately contain@angular/corestart demo
ng serve --preserve-symlinksaffects error:messy workaround
removing
demo/node_modules/angular2gridster/node_modules/@angular/coresolves the problem temporary but after that we can't rebuild library.
path mapping inside
demo/src/tsconfig.app.jsonalso doesn't help:library dependecies:
demo dependencies:
any idea?
angular-automatic-lock-bot commentedon Sep 7, 2019
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.