Open gravis opened 6 years ago
+1 on a Angular project.
/usr/local/rvm/gems/ruby-2.5.1/gems/license_finder-5.1.0/lib/license_finder/package_managers/npm.rb:35:in `npm_json': Command 'npm list --json --long' failed to execute: npm ERR! peer dep missing: @angular/common@5.2.10, required by @angular/forms@5.2.10 (RuntimeError)
npm ERR! peer dep missing: @angular/common@5.2.10, required by @angular/platform-browser@5.2.10
npm ERR! peer dep missing: @angular/common@5.2.10, required by @angular/platform-browser-dynamic@5.2.10
npm ERR! peer dep missing: @angular/common@5.2.10, required by @angular/router@5.2.10
npm ERR! peer dep missing: @angular/core@5.2.11, required by @angular/animations@5.2.11
npm ERR! peer dep missing: @angular/core@5.2.11, required by @angular/common@5.2.11
npm ERR! peer dep missing: @angular/core@^4.0.0, required by angular2-powerbi@0.1.1
I'm having the same issue as well. Anyone figure out a solution?
I'm going to follow up on a couple things I did to reduce some of the errors.
So after locally looking at the output of npm list --json --long
I did some research.
rm -r node_modules package-lock.json
npm install --no-optional
npm dedupe
This now left me with 1 ERR!
npm ERR! peer dep missing: @angular/core@^4.0.0, required by angular2-powerbi@0.1.1
No matter how many I have, LicenseFinder always fails when there are missing peer dependencies 😢
Command 'npm list --json --long --production' failed to execute: npm ERR! peer dep missing: X, required by Y(RuntimeError)
I am also having same problem. Is there any workaround for this?
The issue is here.
Looks like when a package has unmet peer dependencies, npm will return a list of the missing peer dependencies in stderr. An exception is raised in this case even though stdout still contains the valid data needed for license extraction.
This is probably NOT the correct way to permanently fix this as it may blow up if there are more than peer dependency errors present. But if the only error is regarding unmet peer dependencies, the below work around should work in a pinch.
def npm_json
command = "#{NPM.package_management_command} list --json --long#{production_flag}"
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
if not status.success? and not stderr.include? "npm ERR! peer dep missing:"
raise "Command '#{command}' failed to execute: #{stderr}"
end
JSON.parse(stdout)
end
When using LicenseFinder on npm projects, we often have an error exit.
It's using
npm install
andnpm list
under the hood to get a list of dependencies, butnpm list
fails with:(with the project https://gitlab.com/gitlab-org/security-products/tests/js-npm for example)