简体   繁体   English

清理node_modules后缺少软件包

[英]Missing packages after cleaning node_modules

I had an issue: npm run watch was stuck after 10%, so I deleted node_modules directory and package-lock.json But I guess I installed modules with npm install without using --save-dev, and after having reinstalled several of them I still get a warning and can't identify which package is missing here... 我有一个问题:npm run watch在10%之后卡住了,所以我删除了node_modules目录和package-lock.json但我想我在不使用--save-dev的情况下使用npm install安装了模块,并且在重新安装了其中的几个模块后,仍然会收到警告,无法识别此处缺少哪个软件包...

WARNING in ./resources/js/components/common/ContenuComponent.vue?vue&type=style&index=0&id=1a3ffd6c&scoped=true&lang=css& (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/laravel-mix/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/common/ContenuComponent.vue?vue&type=style&index=0&id=1a3ffd6c&scoped=true&lang=css&)
Module Warning (from ./node_modules/css-loader/dist/cjs.js):
Warning

(476:2) Unable to find uri in 'background:url() no-repeat top left black'
 @ ./resources/js/components/common/ContenuComponent.vue?vue&type=style&index=0&id=1a3ffd6c&scoped=true&lang=css& (./node_modules/style-loader!./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/laravel-mix/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/common/ContenuComponent.vue?vue&type=style&index=0&id=1a3ffd6c&scoped=true&lang=css&) 2:14-388
 @ ./resources/js/components/common/ContenuComponent.vue?vue&type=style&index=0&id=1a3ffd6c&scoped=true&lang=css&
 @ ./resources/js/components/common/ContenuComponent.vue
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js ./resources/sass/app.scss

I did: 我做了:

  • npm install postcss-loader --save-dev npm安装postcss-loader --save-dev

  • npm install style-loader --save-dev npm安装样式加载器--save-dev

  • npm install css-loader --save-dev npm安装css-loader --save-dev

  • npm install file-loader --save-dev npm安装文件加载器--save-dev

  • npm install vue-loader --save-dev npm安装vue-loader --save-dev

    Is there any way to identify what I am missing? 有什么方法可以识别我所缺少的吗? Thanks a lot! 非常感谢!

when you remove package-lock.json , you remove references about which specific versions of each package were installed before. 删除package-lock.json ,将删除有关之前安装了每个软件包的特定版本的引用。 My guess is that there was an issue published within the css-loader module, which seems to be a dependency of a dependency of Laravel. 我的猜测是在css-loader模块内发布了一个问题,该问题似乎与Laravel的依赖有关。

The easiest fix would be bringing back package-lock.json , removing node_modules again and reinstalling with npm install . 最简单的修复方法是恢复package-lock.json ,再次删除node_modules并使用npm install重新npm install

There are few things you can try based on the information you have provided. 您可以根据提供的信息尝试几种方法。 You can try npm cache clean or npm cache clean --f (this is a force, which will ask you if you know what you are doing, you can proceed with the force). 您可以尝试使用npm cache clean或npm cache clean --f(这是一种强制措施,它将询问您是否知道自己在做什么,可以继续使用强制措施。) Once the cache has been cleaned, you can try running npm install again. 清除缓存后,您可以尝试再次运行npm install。 Also check your version of NodeJS and make sure that whatever packages you're using is also supporting the version. 还要检查您的NodeJS版本,并确保您使用的任何软件包也支持该版本。 Node -V and check and make sure that css loader supports your version of node. 节点-V并检查并确保CSS加载程序支持您的节点版本。

After I thought it had been fixed, I got the issue again today (worst actually, this time it was an error). 我以为已解决问题之后,今天又遇到了问题(实际上,最糟糕的是,这是一个错误)。 So I went back to package-lock.json old version and after many tries and another hours lost, it worked. 因此,我回到了package-lock.json的旧版本,经过多次尝试和另一个小时的努力,它仍然有效。

I guess this is gonna happen again and obviously I cannot do that because I will add other packages in the future. 我想这将再次发生,显然我不能这样做,因为将来我会添加其他软件包。 I am wondering if there is any way to add all missing packages in package.json dev dependencies? 我想知道是否有任何方法可以在package.json开发依赖项中添加所有缺少的软件包? I have no idea how to identify them? 我不知道如何识别它们?

It seems like npm install ls node_modules --save was working some years ago, so I m trying to dind something like this but reading in package-lock.json maybe (am I dreaming? :) ) 看起来npm install ls node_modules --save几年前就在工作,所以我试图找出类似的东西,但可能是在package-lock.json中读取(我在做梦吗?:))

Thanks a lot 非常感谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM