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

How to install the library having angular 14 #563

Open
vladyslav-fenchak opened this issue Jul 19, 2022 · 3 comments
Open

How to install the library having angular 14 #563

vladyslav-fenchak opened this issue Jul 19, 2022 · 3 comments

Comments

@vladyslav-fenchak
Copy link

Hello.
I have a question about the library. The last release I see is 3 years old, however in master it is updated to be compatible with version 14 of angular.
Can you tell me how I can use this library with angular 14?

Thanks.

@b-turchyn
Copy link

I haven't seen much movement in this repo recently unfortunately, so I'm not sure when/if a new version will be updated.

In general though, NPM can install packages from GitHub repos with the following syntax:

# From the main/master primary branch
npm install neroniaky/angular-token # main/master
# From a specific branch
npm install neroniaky/angular-token#branch

@KOVIKO
Copy link

KOVIKO commented Nov 16, 2022

@b-turchyn Were you able to actually do that for this repo and then make use of it?

When I try, it creates an angular-token-app directory in node_modules that is nothing but *.json files, *.md files, config files, etc.

image

@KOVIKO
Copy link

KOVIKO commented Nov 17, 2022

This prompted me to start looking for a solution—other than --force or --legacy-peer-deps—to this issue and I've found something that works for me!

As of NPM 8 (~8.3), there's been the ability to set overrides in package.json to override dependencies of your dependencies. Personally, I had no idea. 🤣 You can manually set version strings, or you can use the special character $ to reference whatever version you are currently using in dependencies.

package.json

{
  "scripts": {
    ...
  },
  "dependencies": {
    "@angular/common": "^14.2.10",
    "@angular/compiler": "^14.2.10",
    "@angular/core": "^14.2.10",
    "angular-token": "^7.0.1",
    ...
  },
  "devDependencies": {
    ...
  },
  "overrides": {
    "angular-token": {
      "@angular/common": "$@angular/common",
      "@angular/compiler": "$@angular/compiler",
      "@angular/core": "$@angular/core"
    }
  }
}

It's worth noting that the overrides section of the config does not appear to have any effect on the resulting package-lock.json/npm-shrinkwrap.json. As such, if you want to be able to run npm ci, you must include the package.json in your container. The package-lock.json/npm-shrinkwrap.json file is not enough.

I also personally found that I had to include tslint in my devDependencies for angular-token to install via this method. The error messages from NPM made this abundantly clear, however.

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