Skip to content

Do not stop process when EPEERINVALID error is raised #2087

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

Merged
merged 1 commit into from
Sep 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions lib/node-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface INpmOpts {

export class NodePackageManager implements INodePackageManager {
constructor(private $childProcess: IChildProcess,
private $logger: ILogger,
private $options: IOptions) { }

public getCache(): string {
Expand Down Expand Up @@ -37,15 +38,46 @@ export class NodePackageManager implements INodePackageManager {
}

public install(packageName: string, pathToSave: string, config?: any): IFuture<any> {
if (this.$options.disableNpmInstall) {
return Future.fromResult();
}
if (this.$options.ignoreScripts) {
config = config || {};
config["ignore-scripts"] = true;
}
return (() => {
if (this.$options.disableNpmInstall) {
return;
}
if (this.$options.ignoreScripts) {
config = config || {};
config["ignore-scripts"] = true;
}

return this.loadAndExecute("install", [pathToSave, packageName], { config: config });
try {
return this.loadAndExecute("install", [pathToSave, packageName], { config: config }).wait();
} catch (err) {
if (err.code === "EPEERINVALID") {
// Not installed peer dependencies are treated by npm 2 as errors, but npm 3 treats them as warnings.
// We'll show them as warnings and let the user install them in case they are needed.
// The strucutre of the error object in such case is:
// { [Error: The package @angular/[email protected] does not satisfy its siblings' peerDependencies requirements!]
// code: 'EPEERINVALID',
// packageName: '@angular/core',
// packageVersion: '2.1.0-beta.0',
// peersDepending:
// { '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@angular/[email protected]': '2.1.0-beta.0',
// '@ngrx/[email protected]': '^2.0.0',
// '@ngrx/[email protected]': '^2.0.0',
// '[email protected]': '~2.0.0' } }
this.$logger.warn(err.message);
this.$logger.trace("Required peerDependencies are: ", err.peersDepending);
} else {
// All other errors should be handled by the caller code.
throw err;
}
}
}).future<any>()();
}

public uninstall(packageName: string, config?: any, path?: string): IFuture<any> {
Expand Down