Skip to content

Angular CLI v8 ng new generates Angular v7 files #14603

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
DeborahK opened this issue May 31, 2019 · 7 comments · Fixed by #24234
Closed

Angular CLI v8 ng new generates Angular v7 files #14603

DeborahK opened this issue May 31, 2019 · 7 comments · Fixed by #24234
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@DeborahK
Copy link
Contributor

🐞 Bug report

Command (mark with an x)

- [x ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Probably not

Yes, the previous version in which this bug was not present was...

Description

A clear and concise description of the problem...

The package.json file created with ng new is set to version 7 files instead of version 8 files.

🔬 Minimal Reproduction

  1. Installed Angular CLI v8.01
  2. ng new myApp
  3. Opened the package.json file and the versions are set to 7.x
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },

🔥 Exception or Error





🌍 Your Environment



Angular CLI: 8.0.1
Node: 10.15.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.800.1
@angular-devkit/core         8.0.1
@angular-devkit/schematics   8.0.1
@schematics/angular          8.0.1
@schematics/update           0.800.1
rxjs                         6.4.0


Anything else relevant?

@DeborahK
Copy link
Contributor Author

This issue was resolved by removing an errant node-modules folder. It appears that it invokes the local CLI when one exists and one existed in the node-modules folder.

Suggested change (from Filipe): "We can detect whether or not the command runs in a workspace and that should bound the mechanism for using the local version."

@alan-agius4 alan-agius4 added area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix labels May 31, 2019
@ngbot ngbot bot added this to the Backlog milestone May 31, 2019
@markgoho
Copy link
Contributor

markgoho commented Jun 2, 2019

I don't know if this picture is accurate, but what it sounds like is that you were in a directory with a node_modules folder that contained v7 of the Angular CLI and when running ng new myApp it installed Angular v7.

After removing the node_modules folder, and running the command again, npm used the global version of the Angular CLI (v8) and installed v8 of Angular.

If this is accurate, there isn't a bug here, this is just the way node and npm work.

@mgechev
Copy link
Member

mgechev commented Jun 11, 2019

Maybe it's worth outputting a warning message to set clear expectations.

@clydin
Copy link
Member

clydin commented Jun 12, 2019

ng new is intended to be a global command. The problem here is that it is also a local command (albeit a non-functional local command if within a workspace).

@rubiesonthesky
Copy link

I have problem where the new project is Angular 6. Global cli is latest.

$ npm list -g --depth=0
/Users/<user>/.nvm/versions/node/v12.4.0/lib
├── @angular/cli@8.0.2
└── npm@6.9.0

The directory where I'm using ng new doesn't have any modules installed.

$ npm list
/Users/<user>/code
└── (empty)
$ ng --version

Angular CLI: 6.0.8
Node: 12.4.0
OS: darwin x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    <error>
@angular-devkit/core         <error>
@angular-devkit/schematics   <error>
@schematics/angular          <error>
@schematics/update           <error>
rxjs                         <error>

The directory where using ng new command has a lot other Angular project directories, can it be that ng tries to use @angular/cli from some subdirectory's node_modules?

@abierbaum
Copy link

I just ran into this issue for several hours. I had a node_modules directory in the directory I was running ng new from and didn't realize it. Would definitely be nice to have a warning message.

@dgp1130 dgp1130 added the 2022Q3 Fixit Candidates for the Q3 2022 fix-it label Jun 27, 2022
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Nov 15, 2022
In some cases orphan `node_modules` could cause the non global CLI to be used to generate a new workspace.

Closes angular#14603
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Nov 15, 2022
In some cases orphan `node_modules` would cause the non global CLI to be used to generate a new workspace.

Closes angular#14603
dgp1130 pushed a commit that referenced this issue Nov 16, 2022
In some cases orphan `node_modules` would cause the non global CLI to be used to generate a new workspace.

Closes #14603
dgp1130 pushed a commit that referenced this issue Nov 16, 2022
In some cases orphan `node_modules` would cause the non global CLI to be used to generate a new workspace.

Closes #14603

(cherry picked from commit 412cb3e)
dgp1130 pushed a commit to dgp1130/angular-cli that referenced this issue Nov 17, 2022
In some cases orphan `node_modules` would cause the non global CLI to be used to generate a new workspace.

Closes angular#14603
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants