Angular-cli: Install latest versions of dependencies with ng new

Created on 24 Jun 2017  路  14Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Versions.


ng --version: 3.10.10
@angular/[email protected]

Repro steps.


Run ng new <...>

The log given by the failure.


(N/A)

Desired functionality.


I want to immediately install the latest versions of a newly generated project's package.json dependencies without having to install @angular/<everything>@latest after initializing the project. For instance, when I ran ng new, I got v 4.0.0 on all @angular dependencies, but installing @latest gives me 4.2.4.

Mention any other details that might be useful.

Most helpful comment

I'm seeing this as well, yet there is no @angular/* in local npm cache
May be an nvm env quirk?
Additionally @robertbaker I'd guess you'd meant ncu -u -a.

All 14 comments

You can accomplish this by using npm i -g npm-check-updates and run ncu -u -q and it will update all of your dependencies to the latest.

@robertbaker Thank you for that tip. That does make it a lot easier. I still think there should be a CLI option or something to install latest from the start.

That really depends on your local npm cache, not the CLI. When I make a new project, I get the latest versions of Angular for instance.

You can use npm cache clean if you're using npm. You might also be behind a npm proxy. https://www.npmjs.com/ or https://github.com/npm/npm should have more information about how to keep your cache up to date.

I'm seeing this as well, yet there is no @angular/* in local npm cache
May be an nvm env quirk?
Additionally @robertbaker I'd guess you'd meant ncu -u -a.

@filipesilva the package.json file is generated and npm would be installing the version that is in the package.json file. So I don't get how cleaning the cache will help.

@mitulgohil package.json has ranges for dependencies, like "@angular/core": "^4.0.0",. If your cache has a version that can satisfy the range, for instance 4.1.0, then it will use that instead of the latest available version.

@filipesilva Thanks for the info, I have cleaned the cache using npm cache clean --force and have generated a new app using ng new but i still get the same package.json with angular 4.0 instead of 4.3

If you have ranges in your package.json and aren't getting the latest version even with a clean cache, then there's something else happening like a npm proxy. You'll have to debug your specific setup, there isn't much we can do on the CLI side about that... it's related to how npm works.

@filipesilva Hi, even I'm facing this issue. I have tested on 3 different macos:

  1. Installed cli using npm install -g @angular/cli.
  2. created a new angular project using ng new test-angular
  3. output of the above command is as below:
installing ng
  create .editorconfig
  create README.md
  create src/app/app.component.css
  create src/app/app.component.html
  create src/app/app.component.spec.ts
  create src/app/app.component.ts
  create src/app/app.module.ts
  create src/assets/.gitkeep
  create src/environments/environment.prod.ts
  create src/environments/environment.ts
  create src/favicon.ico
  create src/index.html
  create src/main.ts
  create src/polyfills.ts
  create src/styles.css
  create src/test.ts
  create src/tsconfig.app.json
  create src/tsconfig.spec.json
  create src/typings.d.ts
  create .angular-cli.json
  create e2e/app.e2e-spec.ts
  create e2e/app.po.ts
  create e2e/tsconfig.e2e.json
  create .gitignore
  create karma.conf.js
  create package.json
  create protractor.conf.js
  create tsconfig.json
  create tslint.json
Installing packages for tooling via npm.
Successfully initialized git.
Project 'test-angular' successfully created.

The project creation takes a 1 sec.

This is the package.json that is generated -

{
  "name": "test-angular",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.2.1",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

Also my npm version is 4.1.2

@filipesilva And packages are not installed by default. I have to npm install the packages. After npm install i can see that angular version has been incremented to 4.3 in node_modules but of-course package.json doesn't reflect that change. I think I can use Yarn to install and also create a lock file so that my dependencies are fixed.

Thanks for the help. Would have loved to have the feature of package.json reflecting what is installed in node_modules so it becomes easy to rationale about project dependencies but this will do for now.

HI! I'm checking how it works ng to retrieve the blueprings to generate a new project, and I realized that no depends on my local npm cache but on from @schematics/angular. You can check out here.

screen shot 2018-07-10 at 12 37 42

This is what I get having issued following from terminal on OSX EL Capitan:
"ng new ng5Routes"

I would have expected as other posts have suggested to have references to the latest versions of angular :-( Come on angular team update your bolier plates :-)

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._

Was this page helpful?
0 / 5 - 0 ratings