Skip to content

Issue with npm link #10

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

Closed
pauljeter opened this issue Apr 14, 2016 · 5 comments
Closed

Issue with npm link #10

pauljeter opened this issue Apr 14, 2016 · 5 comments

Comments

@pauljeter
Copy link

I am experiencing an issue with a generated ng2-library when attempting to npm link into a project using webpack. I created an ng2-library-test from the generator, and did not change any of the boilerplate code. I published the library to npm at ng2-library-test and installed it in a boilerplate project here. When I run the project all works as expected. However, when I npm link the library locally, I get errors when trying to run the project:

ERROR in ../ng2-library-test/ng2-library-test.js
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.js 5:19-46 8:9-36

ERROR in ../ng2-library-test/ng2-library-test.js
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.js 6:14-36 10:9-31

ERROR in ../ng2-library-test/ng2-library-test.js
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.js 7:17-42 9:9-34

ERROR in ../ng2-library-test/ng2-library-test.ts
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.ts 5:19-46 8:9-36

ERROR in ../ng2-library-test/ng2-library-test.ts
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.ts 6:14-36 10:9-31

ERROR in ../ng2-library-test/ng2-library-test.ts
Module not found: Error: Cannot resolve module 'awesome-typescript-loader' in /Users/ng2-library-test
 @ ../ng2-library-test/ng2-library-test.ts 7:17-42 9:9-34

Any ideas? Have you been able to npm link with a generated library successfully?

@jbeckton
Copy link

While I am not using Webpack but SystemJs I have been struggling with a Linked library project for a day or two myself. The typescript compiler shows errors on the app side because of the /// references in your library ts code. If you remove them then your app will compile but your library will not. The only way to get your library ts to compile without the /// ref path is to add all your files to the tsconfig files array pulling in the node_modules/angular2/typings/browser.d.ts first and then your library ts files. I did not want to maintain this files array manually so I used a Gulp tool to build my tsconfig file from file globs "https://www.npmjs.com/package/gulp-tsconfig". This so far has solved my problems on both sides.

This issue will most likely only occur when you have a linked npm package project with typescript files, not sure there is much the developer of this project can do about it, I just had to get creative in order to fix mine.

Hope this helps

@jvandemo
Copy link
Owner

@pauljeter — Can you let me know if @jbeckton's suggestion of adding the library to files in tsconfig.json (as discussed in #9) solved your problem?

If so, I will add additional documentation to the README to instruct others how to actually consume a library in an application.

Thanks in advance!

@jbeckton — Thank you for your input!

@pauljeter
Copy link
Author

Sorry, I was a AFK this weekend. I will try and report back.

@jvandemo
Copy link
Owner

@pauljeter — Thank you!

@jvandemo
Copy link
Owner

@pauljeter — Will close this issue for now. Feel free to re-open if you think it is still an issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants