Giter VIP home page Giter VIP logo

install-peers-cli's Introduction

install-peers-cli

CLI to install project's peerDependencies, without side effects. Works with npm, yarn. Supports yarn workspaces flow.

Install

yarn

$ yarn add --dev install-peers-cli

npm

$ npm install --save-dev install-peers-cli

Usage

Add package.json script:

{
  "scripts": {
    "install-peers": "install-peers"
  }
}

Then run yarn install-peers (or npm run install-peers) to install peer dependencies of your project. It won't update lock files or modify package.json, keeping your setup pure and clean. Any other lifecycle script could be used depending on your use case.

You still may see "unmet peer dependency" warnings during regular install phase, due to installation flow of npm/yarn.

License

Install-Peers-CLI is released under the MIT license.

install-peers-cli's People

Contributors

alexindigo avatar chris-verclytte avatar juliaqiuxy avatar yapuka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

install-peers-cli's Issues

installation instructions don't actually work

I saw a closed issue with this, but I followed these steps:

  1. yarn add -D install-peers-cli
  2. add this script to package.json:
    "install-peers": "install-peers"
  3. run yarn install-peers

And it gives me:

➜  gollum git:(experiment/cypress) ✗ yarn install-peers
yarn run v1.19.1                                                                                                                                              
$ install-peers                                                                                                                                               
Only run install-peer-deps after `install` command. Skipping.

I saw the note about postinstall, but the reason I am using a peer dependency is that I don't want it to be installed on CI, because it breaks the build. It is only for local dev. So I can't add it to postinstall.

npm run won't work

os: windows
>npm run install-peers
result:

 > install-peers -f
>

>yarn install-peers

result:

yarn run v1.22.4
$ install-peers -f
- Installing 40 peerDependencies...
+ Successfully installed 40 peerDependencies via yarn.

I think it is something related to welcome string chars: > and $

Can't find react in registry when run as prepare script

When I execute yarn install, I see this:

.
.
.
$ install-peers
- Installing 2 peerDependencies...
Unable to install peerDependencies Error: Command failed: "/Users/dkreft/.nvm/versions/node/v12.18.4/bin/node" "/usr/local/Cellar/yarn/1.22.10/libexec/bin/yarn.js" add  --peer --pure-lockfile "react@^16.9" "react-dom@^16.9"
error Couldn't find package "react" on the "npm" registry.
    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:674:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '"/Users/dkreft/.nvm/versions/node/v12.18.4/bin/node" "/usr/local/Cellar/yarn/1.22.10/libexec/bin/yarn.js" add  --peer --pure-lockfile "react@^16.9" "react-dom@^16.9"',
  stdout: 'yarn add v1.22.10\n' +
    '[1/4] Resolving packages...\n' +
    'info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.',
  stderr: `error Couldn't find package "react" on the "npm" registry.`
}
verbose 1.392749916 Error: Command failed with exit code 1.
    at ProcessTermError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:721:66)
    at ProcessTermError.MessageError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:750:123)
    at new ProcessTermError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:790:113)
    at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:34550:30
    at Generator.throw (<anonymous>)
    at step (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:310:30)
    at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:323:13
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
error Command failed with exit code 1.

Yet when I run the command manually, it works just fine:

% /Users/dkreft/.nvm/versions/node/v12.18.4/bin/node "/usr/local/Cellar/yarn/1.22.10/libexec/bin/yarn.js" add  --peer --pure-lockfile "react@^16.9" "react-dom@^16.9"
yarn add v1.22.10
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved 2 new dependencies.
info Direct dependencies
├─ [email protected]
└─ [email protected]
info All dependencies
├─ [email protected]
└─ [email protected]
$ install-peers
Only run install-peer-deps after `install` command. Skipping.
✨  Done in 2.83s.

I do have an ~/.npmrc...could it be that your script isn't honoring it?

@myscope:registry=https://npm.pkg.github.com/
registry=https://registry.npmjs.org/
//npm.pkg.github.com/:_authToken=REDACTED_TOKEN

Here's the diff of my package.json:

diff --git a/package.json b/package.json
index 9d888fb..9497b9f 100644
--- a/package.json
+++ b/package.json
@@ -31,12 +31,11 @@
     "eslint-plugin-react-perf": "^3.3.0",
     "husky": "^4.3.6",
     "identity-obj-proxy": "^3.0.0",
+    "install-peers-cli": "^2.2.0",
     "jest": "^26.6.3",
     "jest-enzyme": "^7.1.2",
     "process": "^0.11.10",
     "prop-types": "^15.7.2",
-    "react": "16.9",
-    "react-dom": "16.9",
     "react-styleguidist": "^11.1.5",
     "sass": "^1.30.0",
     "sass-loader": "^10.1.0",
@@ -45,7 +44,8 @@
     "webpack-cli": "^4.2.0"
   },
   "peerDependencies": {
-    "react": "^16.9"
+    "react": "^16.9",
+    "react-dom": "^16.9"
   },
   "scripts": {
     "build": "webpack --mode production",
@@ -54,7 +54,8 @@
     "build:styleguide": "styleguidist build",
     "lint": "eslint src *.js .*.js --ext .js,.jsx",
     "test": "jest --watch",
-    "test:coverage": "jest --no-cache --coverage"
+    "test:coverage": "jest --no-cache --coverage",
+    "prepare": "install-peers"
   },
   "husky": {
     "hooks": {

Always getting skipping message

Only run install-peer-deps after \install` command. Skipping.`

No matther what I do. The instructions are pretty straightforward.
I get the same message both after normal npm install or npm run install-peers.

Windows 10
Node 11

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.