npm link shouldn't install peerDependencies

When I use npm link to link a package with a React project, I get “multiple instances of React” errors. This wouldn’t happen if npm link didn’t install packages listed in peerDependencies.

I’ve been using the following script instead of npm link by itself:

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');

execSync('npm link');

const packagePath = path.join(process.cwd(), 'package.json');
const packageData = JSON.parse(fs.readFileSync(packagePath, 'utf8'));

Object.keys(packageData.peerDependencies).forEach((peerDep) => {
  const dirPath = path.join(process.cwd(), 'node_modules', peerDep);

  rimraf.sync(dirPath);
});