简体   繁体   English

如何强制 npm 使用 jquery 2.1.1

[英]How to force npm to use the jquery 2.1.1

I am asking this question as a beginner on node-npm.我是作为 node-npm 的初学者问这个问题的。 My current node_modules has a query version 2.2.0.我当前的 node_modules 有一个查询版本 2.2.0。 But in the same project i am using materialize-css which has a datepicker component.但在同一个项目中,我正在使用具有日期选择器组件的 materialize-css。

This component runs on jquery 2.1.1.该组件在 jquery 2.1.1 上运行。 My question is simple.我的问题很简单。

How can i remove the current jquery [v 2.2.0] from my node_modules and install jquery version [2.1.1] so that the datepicker component works.如何从我的 node_modules 中删除当前的 jquery [v 2.2.0] 并安装 jquery 版本 [2.1.1] 以便 datepicker 组件工作。

Add the specific version to your package.json :将特定版本添加到您的package.json

"dependencies": {
    "jquery": "2.1.1"
}

Then, run the following command :然后,运行以下命令

npm update

您可以使用 npm CLI 直接安装依赖项,而无需自己在 package.json 中输入以下内容更改依赖项:

npm install jquery@2.1.1

Thanks for helping out.感谢您的帮助。 I went to my package.json file and added dependency as我去了我的 package.json 文件并添加了依赖项

"dependencies": {
  "jquery": "2.1.1"
}

after this I did sudo npm update to the existing project and it changed the jquery version to 2.1.1.在此之后,我对现有项目进行了sudo npm update ,并将 jquery 版本更改为 2.1.1。 I assume sudo npm install would also have same effect我认为sudo npm install也会有同样的效果

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

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