【问题标题】:Vue.js node_modules folder different on server when build构建时服务器上的 Vue.js node_modules 文件夹不同
【发布时间】:2020-05-03 07:50:44
【问题描述】:

node_modules 已安装,但在构建实时应用程序后会出现本地计算机上不存在的问题

  • 我有一台运行 Ubuntu 操作系统的服务器,我将它用于 Vue.js 应用程序。
  • 当我在服务器上 npm installnpm build 时,实时应用程序会遇到一些设计和功能问题(在我的 MacBook 上它运行良好)。
  • 我让它工作的唯一解决方案是将服务器 node_modules 文件夹替换为我另一台 PC(也使用 Ubuntu)中的 node_modules 文件夹。
  • 这个问题阻碍了我在项目中使用新包。

如果有人可以帮助我,我会很高兴。

package.json

{
  "version": "2.0.0",
  "private": true,
  "scripts": {
    "dev": "vue-cli-service serve --open",
    "free_dev": "vue-cli-service serve --open --mode free_development",
    "staging": "vue-cli-service serve --open --mode staging",
    "free_staging": "vue-cli-service serve --open --mode free_staging",
    "build_staging": "vue-cli-service build --mode staging",
    "build_free_staging": "vue-cli-service build --mode free_staging",
    "build_production": "vue-cli-service build --mode production",
    "build_free_production": "vue-cli-service build --mode free_production",
    "lint": "vue-cli-service lint",
    "build_production-report": "vue-cli-service build --mode production --report",
    "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
    "now-start": "vue-cli-service serve",
    "test:e2e": "vue-cli-service test:e2e",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "axios": "^0.19.0",
    "core-js": "^2.6.10",
    "firebase": "^6.6.2",
    "moment": "^2.24.0",
    "prerender-spa-plugin": "^3.4.0",
    "v-money": "^0.8.1",
    "vue": "^2.6.10",
    "vue-head": "^2.1.2",
    "vue-i18n": "^8.15.0",
    "vue-router": "^3.0.3",
    "vue-the-mask": "^0.11.1",
    "vuetify": "^2.1.6",
    "vuetify-toast-snackbar": "^0.6.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.12.1",
    "@vue/cli-plugin-e2e-cypress": "^3.12.1",
    "@vue/cli-plugin-eslint": "^3.12.1",
    "@vue/cli-plugin-unit-jest": "^3.12.1",
    "@vue/cli-service": "^3.12.1",
    "@vue/eslint-config-standard": "^4.0.0",
    "@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",
    "compression-webpack-plugin": "^3.1.0",
    "eslint": "^5.16.0",
    "eslint-config-vuetify": "*",
    "eslint-plugin-vue": "^5.0.0",
    "node-sass": "^4.13.0",
    "pug": "^2.0.4",
    "pug-plain-loader": "^1.0.0",
    "sass": "^1.23.1",
    "sass-loader": "^7.3.1",
    "vee-validate": "^2.2.15",
    "vue-chartist": "^2.2.1",
    "vue-cli-plugin-eslint-config-vuetify": "latest",
    "vue-cli-plugin-i18n": "^0.6.0",
    "vue-cli-plugin-vuetify": "^1.1.1",
    "vue-cli-plugin-vuetify-essentials": "^0.7.0",
    "vue-template-compiler": "^2.6.10",
    "vue-world-map": "^0.1.1",
    "vuetify-loader": "^1.2.2",
    "webpack-bundle-analyzer": "^3.6.0"
  }
}

【问题讨论】:

标签: vue.js build node-modules ubuntu-18.04 package.json


【解决方案1】:

确保将package-lock.json 文件也复制到服务器上,而不仅仅是package.json。这样,您将确保 npm 在您的服务器上安装与本地安装的完全相同版本的所有软件包。

您可以阅读有关package-lock.json 文件here 的更多信息。

您可以随时复制您的package-lock.json 文件并运行npm install 将确保您的节点模块都处于正确的版本。

【讨论】:

    【解决方案2】:
    • 尝试从服务器中删除 node_modules 并再次执行 npm install
    • 确保nodenpm 版本——但这不应该是问题
    • 如果存在,请删除 package.lock 文件并再次执行 npm install
    • 确保下载依赖项时没有任何错误

    【讨论】:

      猜你喜欢
      • 2021-03-04
      • 1970-01-01
      • 2021-03-21
      • 2018-11-13
      • 2015-06-05
      • 2017-07-11
      • 2022-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多