Giter Site home page Giter Site logo

Comments (12)

ljharb avatar ljharb commented on September 26, 2024 4

I would expect the npm install command to be @^7 and not @7.0.0 or @7.4.0 - that seems like a bug.

from install-peerdeps.

ljharb avatar ljharb commented on September 26, 2024

You could use ^3.8 for that tho, any reason you’re not?

from install-peerdeps.

erhhung avatar erhhung commented on September 26, 2024

@ljharb I think ^3.8 would still get parsed into @3.8.0, which is a non-existent version. Regardless of the semver syntax, my point is that this tool should handle whatever that is considered valid in a package.json file.

from install-peerdeps.

erhhung avatar erhhung commented on September 26, 2024

BTW, my workaround to this issue seems to completely obviate the need for install-peerdeps:

npm info <package> peerDependencies --json | jq -r 'keys[] as $k | "\($k)@\"\(.[$k])\""' | xargs npm install --save-dev

from install-peerdeps.

ljharb avatar ljharb commented on September 26, 2024

No, it wouldn’t - the caret is an identical (and simpler and more widely understood) range than the one you have.

from install-peerdeps.

ocean90 avatar ocean90 commented on September 26, 2024

I think I have a similar case where ^7 is transformed to 7.0.0 instead of the latest in the 7.x branch.

Example:

❯ npx install-peerdeps --dev @wordpress/eslint-plugin --dry-run
install-peerdeps v2.0.3
This command would have been run to install @wordpress/eslint-plugin@latest:
npm install @wordpress/[email protected] [email protected] --save-dev --registry https://registry.npmjs.org

Source: https://github.com/WordPress/gutenberg/blob/acc6dbea78ab3b8dd5436a57bc0c2d4808ec6756/packages/eslint-plugin/package.json#L44

I'm expecting to get [email protected] here. Is that expectation incorrect?

from install-peerdeps.

karlhorky avatar karlhorky commented on September 26, 2024

Yeah, I believe this is a bug - I think it may be causing facebook/create-react-app#10465 reported by @uebriges.

from install-peerdeps.

karlhorky avatar karlhorky commented on September 26, 2024

Just tested with @uebriges, and it seems this is indeed a problem.

We tested on a Windows 10 machine - not sure if this is a relevant detail.

Failing Repro

Reproduction 1 uses install-peerdeps to install the peer dependencies of eslint-config-react-app. When react-scripts start is run using yarn start, create-react-app crashes, saying that the versions of babel-eslint and eslint do not match the version from react-scripts.

mkdir reproduction
cd reproduction
npx create-react-app .
npx install-peerdeps --yarn --dev eslint-config-react-app
yarn start

Succeeding Repro

Reproduction 2 uses a manual yarn add --dev installation command to install the version ranges from the package.json for eslint-config-react-app. The start script runs without any problems:

mkdir reproduction-two
cd reproduction-two
npx create-react-app .
yarn add --dev eslint-config-react-app @typescript-eslint/eslint-plugin@^4.0.0 @typescript-eslint/parser@^4.0.0 babel-eslint@^10.0.0 eslint@^7.5.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-react@^7.20.3 eslint-plugin-react-hooks@^4.0.8 eslint-plugin-jest@^24.0.0
yarn start

from install-peerdeps.

nathanhleung avatar nathanhleung commented on September 26, 2024

@karlhorky really appreciate your testing here, glad we're squashing all these bugs! Opened #126 which should hopefully fix -- can you let me know if that works for you?

from install-peerdeps.

karlhorky avatar karlhorky commented on September 26, 2024

Sure! @uebriges and I will test: #126 (comment)

from install-peerdeps.

karlhorky avatar karlhorky commented on September 26, 2024

Ah seems like this solution in #126 doesn't work after all (installing the eslint-config-react-app peer deps in a new create-react-app project with [email protected] just failed on Windows).

You can see this with this example dependency:

eslint-config-react-app

    "@typescript-eslint/parser": "^4.0.0",

Source: https://unpkg.com/browse/[email protected]/package.json

Installed via [email protected]

    "@typescript-eslint/parser": "4.0.0",

Latest version of @typescript-eslint/parser

4.14.2

Source: https://www.npmjs.com/package/@typescript-eslint/parser


Let me know if I should open a new issue for this.

from install-peerdeps.

zhiqingchen avatar zhiqingchen commented on September 26, 2024

same problem on a Windows 11 machine

from install-peerdeps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.