【问题标题】:How to solve NPM issue needing multiple versions of same dependency?如何解决需要多个版本的相同依赖项的 NPM 问题?
【发布时间】:2019-04-20 04:00:02
【问题描述】:

我正在尝试构建一个 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.

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

【问题讨论】:

    标签: laravel npm dependencies laravel-nova


    【解决方案1】:

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

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

    单独运行每一行。

    【讨论】:

    • 是的,我已经在我的package.json 文件中使用不同的 webpack 版本多次尝试过,但运气不好。这是我在运行npm install/node_modules/pngquant/node_modules/pngquant-bin/vendor/pngquant 二进制文件时遇到的错误的一部分⚠ pngquant 预构建测试失败`
    • @hoolakoola 你有没有试过在这里寻找一些答案? github.com/imagemin/pngquant-bin/issues/78
    • 啊啊啊终于!谢谢 - 不得不将几个解决方案拼凑在一起,但得到了它的工作。
    • @hoolakoola 太棒了!乐意效劳。请接受答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    • 1970-01-01
    • 2021-04-10
    • 2021-11-14
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多