Skip to content

[Feature]: Switch back to corepack and yarn #976

@trivikr

Description

@trivikr

Self-service

  • I'd be willing to implement this feature

Problem

The aws-sdk-js-codemod adopted official devEngines proposal and switched from yarn to npm in #948

However npm doesn't adapt devEngines wholly, i.e. it doesn't download the version specified if it's not present.

$ aws-sdk-js-codemod> node -v
v22.14.0

$ aws-sdk-js-codemod> npm -v
10.9.2

$ aws-sdk-js-codemod> which npm
/Users/trivikr/.nvm/versions/node/v22.14.0/bin/npm

$ aws-sdk-js-codemod> npm install
npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid engine "packageManager"
npm error EBADDEVENGINES Invalid semver version "10.9.0" does not match "10.9.2" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES   current: { name: 'npm', version: '10.9.2' },
npm error EBADDEVENGINES   required: { name: 'npm', version: '10.9.0', onFail: 'download' }
npm error EBADDEVENGINES }
npm error A complete log of this run can be found in: /Users/trivikr/.npm/_logs/2025-03-14T21_24_26_384Z-debug-0.log

The solution is to explicitly install npm version defined in devEngines as follows

$ aws-sdk-js-codemod> npm install -g [email protected] 

$ aws-sdk-js-codemod> npm install

Solution

Corepack added support for devEngines in nodejs/corepack#643, and it was released in 0.32.0. Switch back to using corepack for managing package manager version.

$ aws-sdk-js-codemod> npm install -g corepack

$ aws-sdk-js-codemod> corepack --version
0.32.0

$ aws-sdk-js-codemod> corepack enable

$ aws-sdk-js-codemod> yarn
! Corepack is about to download https://repo.yarnpkg.com/4.7.0/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n] Y

➤ YN0000: · Yarn 4.7.0
➤ YN0000: ┌ Resolution step
...
➤ YN0000: └ Completed in 1s 666ms
➤ YN0000: · Done with warnings in 2m 6s

Alternatives

Stick with npm, but there seems to be some issue with corepack managing npm version

$ aws-sdk-js-codemod> corepack install
Adding [email protected] to the cache...

$ aws-sdk-js-codemod> npm --version
10.9.2

$ aws-sdk-js-codemod> npm install
npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid engine "packageManager"
npm error EBADDEVENGINES Invalid semver version "10.9.0" does not match "10.9.2" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES   current: { name: 'npm', version: '10.9.2' },
npm error EBADDEVENGINES   required: { name: 'npm', version: '10.9.0', onFail: 'download' }
npm error EBADDEVENGINES }

The main reason we switched to npm was to experiment with devEngines proposal.
We can switch back to yarn as corepack now supports devEngines.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions