npm update 一个模块后,其他模块都不能使用

changli
  • 497
{
  "name": "my-element-ui",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "element-ui": "^2.12.0",
    "vue": "^2.6.10",
    "vue-i18n": "^8.0.0",
    "vue-router": "^3.0.3",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@kazupon/vue-i18n-loader": "^0.3.0",
    "@vue/cli-plugin-babel": "^3.8.0",
    "@vue/cli-plugin-eslint": "^3.8.0",
    "@vue/cli-plugin-unit-jest": "^3.8.0",
    "@vue/cli-service": "^3.8.0",
    "@vue/eslint-config-prettier": "^4.0.1",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "babel-plugin-component": "^1.1.1",
    "element-theme": "^2.0.1",
    "element-theme-chalk": "^2.12.0",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "koa": "^2.11.0",
    "koa-body": "^4.1.1",
    "koa-cors": "^0.0.16",
    "node-sass": "^4.9.0",
    "sass-loader": "^7.1.0",
    "vue-cli-plugin-element": "^1.0.1",
    "vue-cli-plugin-i18n": "^0.6.0",
    "vue-cli-plugin-webpack-bundle-analyzer": "^1.3.0",
    "vue-template-compiler": "^2.6.10"
  }
}

之前的 element-ui 版本是 2.4.5
然后我执行了 npm update element-ui
看 package.json 已经升级到了
但是我发现重启项目,提示很多模块都找不到,这是什么问题导致
现在我只能删除 node_modules 后重新装

回复
阅读 1.1k
1 个回答

npm update 有个小坑,它会升级你指定的包。但如果这个包依赖了你某个其他包、且这个被依赖的包也在你的 package.json 里,那么它并不会被一并升级。

我猜是你 element-ui 依赖的别的什么的没跟着一起升级所以报错了。

建议使用 npm-checknpm-check-updates 来做升级管理;手动 uninstallinstall 也不是不行。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏