如何解决需要多个相同依赖版本的NPM问题?

时间:2018-11-16 23:35:27

标签: laravel npm dependencies laravel-nova

我正在尝试构建Laravel Nova工具,但是当我尝试安装该工具的依赖项时,出现错误。经过一段时间的尝试来解决之后,它导致webpack需要针对不同依赖关系的多个版本,但是我似乎无法使所有这些一起工作。在我的项目文件夹中,当我运行npm audit fix时,出现以下错误:

npm WARN webpack-cli@3.1.2 requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.

up to date in 6.37s
fixed 0 of 1 vulnerability in 15833 scanned packages
1 vulnerability required manual review and could not be updated

我可以通过将webpack版本更改为最新版本来解决此问题,但是npm run watch不起作用,并且Laravel Nova工具资产仍然无法正确编译。

这是尝试创建nova工具时出现的错误:

npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
....
 The `/mnt/c/Users/me/projects/project/nova-components/Anothertool/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
 ⚠ pngquant pre-build test failed
 ℹ compiling from source
 ✔ pngquant pre-build test passed successfully
 ✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at Promise.all.then.arr (/mnt/c/Users/me/projects/project/nova-components/Anothertool/node_modules/pngquant-bin/node_modules/bin-build/node_modules/execa/index.js:231:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pngquant-bin@4.0.0 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pngquant-bin@4.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这个问题困扰了我几天,无论我做什么或更改,我都无法解决。当安装不同版本的软件包时,我不断收到不同的错误。我该怎么做才能解决此问题?

1 个答案:

答案 0 :(得分:-1)

您是否尝试过像这样重新运行它:

// within your project root directory
rm -rf node_modules package-lock.json yarn.lock
npm cache clear --force
npm install

分别运行每一行。