Skip to content

ng update not compatible with yarn #11694

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
mackelito opened this issue Jul 27, 2018 · 20 comments
Closed

ng update not compatible with yarn #11694

mackelito opened this issue Jul 27, 2018 · 20 comments
Labels
freq2: medium P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix
Milestone

Comments

@mackelito
Copy link

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

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

Versions

Repro steps

We have been using yarn for some time now and it has been working fine.. but now with "ng update" it feels as yarn.lock file is not used properly?

Running ng update tells me @angular/cli needs update.. then running ng update @angular/cli does nothing but tell me that all looks good.. ?

To get rid of this issue I can just run npm install to generate the package-lock.json file and then run ng update @angular/cli and it works..

@hansl hansl changed the title Should we use npm instead of yarn? ng update not compatible with yarn Jul 28, 2018
@hansl hansl added comp: schematics/update P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful freq2: medium severity3: broken type: bug/fix labels Jul 28, 2018
@freemanlam
Copy link

same issue here

@awacode21
Copy link

Hi,

i am currently deciding wether to use npm or yarn for my angular project. I would prefer yarn. Therefore i would like to ask if the described problem still exist?

Regards, Annick

@todd-skelton
Copy link

I'm still having this issue but adding --from=x.x.x to the command is a workaround.

@jessenic
Copy link

Same issue. We don't even have npm installed because of some issues it has caused while using 100% yarn in our projects. The --from workaround doesn't seem to work either.

node_modules\@schematics\update\update\npm.js:44
                throw error;
                ^

Error: Command failed: npm get registry
'npm' is not recognized as an internal or external command,
operable program or batch file.

    at ChildProcess.exithandler (child_process.js:276:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)

@clydin
Copy link
Member

clydin commented Oct 24, 2018

Please ensure that you have specified yarn as the project's package manager.

The following should be present within the angular.json file:

  "cli": {
    "packageManager": "yarn"
  }

@a01fe
Copy link

a01fe commented Oct 25, 2018

I'm getting the same error, too. At the top of my angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "cli": {
    "packageManager": "yarn"
  },
  "projects": {

And in ~/.angular-config.json:

{
  "version": 1,
  "cli": {
    "packageManager": "yarn"
  }
}

@clydin
Copy link
Member

clydin commented Oct 25, 2018

@a01fe Do you have npm installed on the system?

@clydin
Copy link
Member

clydin commented Oct 25, 2018

Also, CLI version information would be incredible useful to attempt to troubleshoot the issue.

Unfortunately, some versions will require npm present on the system for ng update to work properly. This will be completely rectified along with greater support for .npmrc files with PR #12526.

@a01fe
Copy link

a01fe commented Oct 25, 2018

@clydin No, npm is not installed. I manually updated @angular/cli with:

yarn global remove @angular/cli
yarn remove @angular/cli
yarn global add @angular/cli
yarn add @angular/cli --dev

Output from ng --version:


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 7.0.3
Node: 10.12.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>

@TheAifam5
Copy link

Looks like a todo:

// TODO: figure out a way to read package-lock.json and/or yarn.lock.

So the yarn on schematics is not supported, there is no class for it.

@clydin
Copy link
Member

clydin commented Oct 25, 2018

That’s related to discovery of installed packages. By that it means to read the lock file instead of manually crawling node modules.
Outside of reading a yarnrc file yarn works with update assuming npm is also installed currently to get registry options form any npmrc files present. But that will be fixed with the above mentioned PR. Which is unfortunately currently blocked on an upstream package PR.

@TheAifam5
Copy link

Why not just use official lockfile package from yarn?
https://www.npmjs.com/package/@yarnpkg/lockfile

for NPM you could use (or clone, or make a new one):
https://github.com/uber/npm-shrinkwrap

@clydin
Copy link
Member

clydin commented Oct 26, 2018

Using the lock file would be a potential optimization for installed package discovery, not a fix for any of the issues discussed in this thread.

@Ksan8
Copy link

Ksan8 commented Dec 7, 2018

We also use Yarn exclusively in our repos, and I would be delighted if we could simply run ng update whenever we felt the need. Thanks in advance for tackling this.

@clydin
Copy link
Member

clydin commented Dec 7, 2018

ng update currently supports yarn usage within the repository. The latest version also supports yarn without npm being installed on the system.
Manually configuring the preferred package manager is also no longer necessary in most cases. The CLI will detect the presence of a yarn.lock file and prefer yarn if installed; assuming there is also not an npm (or soon pnpm) lock file also present. Note however that any configured option takes precedence.

Also, as to the original issue, ng update does not currently (or previously) use package manager lock files in its update logic (npm, yarn, pnpm, or otherwise).

@shireby
Copy link

shireby commented Apr 7, 2019

To ng update with yarn:

ng update --packageManager=yarn

ng update --all --packageManager=yarn

@mackelito
Copy link
Author

To ng update with yarn:

ng update --packageManager=yarn

ng update --all --packageManager=yarn

Should not be needed if yarn is specified in angular.json

"cli": { "packageManager": "yarn" }

@clydin
Copy link
Member

clydin commented Apr 30, 2019

The configuration option is also not needed if a lock file is present within the project. With the exception of when both an npm AND yarn lock file are present; in which case the CLI will default to npm so the setting would be needed in that situation if yarn is preferred.

@clydin
Copy link
Member

clydin commented Sep 19, 2019

Closing this issue as yarn is fully supported with ng update. If any problems are still being encountering regarding the use of yarn, please open a new issue with up to date CLI versions and any details regarding the problem.

@clydin clydin closed this as completed Sep 19, 2019
@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 Oct 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq2: medium P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests