NodeJS Vue.js项目编译错误

dw1jzc5e  于 2023-02-18  发布在  Node.js
关注(0)|答案(1)|浏览(259)

我从我的朋友那里得到了一个vue.js项目。所以我试着在我的本地运行它。但是我做不到。我得到了错误。我不知道我的朋友使用了什么节点版本。我无法预测,所以我仍然使用我的版本。我的版本:节点js 13.8.0国家预防机制6.13.6
我做了两次

error: Unreachable code (no-unreachable) at src/components/MainComponent.vue:64:25:
  62 |                     case 3:
  63 |                         return 'financial-summary';
> 64 |                         break;
     |                         ^
  65 |                     case 4: 
  66 |                         return 'farm-stress';
  67 |                         break;

error: Unreachable code (no-unreachable) at src/components/MainComponent.vue:67:25:
  65 |                     case 4: 
  66 |                         return 'farm-stress';
> 67 |                         break;
     |                         ^
  68 |                     case 5: 
  69 |                         return 'crop-analysis';
  70 |                         break;

error: Unreachable code (no-unreachable) at src/components/MainComponent.vue:70:25:
  68 |                     case 5: 
  69 |                         return 'crop-analysis';
> 70 |                         break;
     |                         ^
  71 |                 }
  72 |             }
  73 |         },

8 errors found.

Module Warning (from ./node_modules/eslint-loader/index.js):
error: 'interest' is already defined (no-redeclare) at src/components/page/FinancialSummary/FinancialChart.vue:79:17:
  77 |         interest () {
  78 |             var interest = (this.$store.state.ProjectedRevenue - this.$store.state.CostProduction) / this.$store.state.CostProduction * 100;
> 79 |             var interest = interest.toFixed(2);
     |                 ^
  80 |             return interest
  81 |         },
  82 |         FarmSelected () {

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:102:17:
  100 |             var ctx = chartRet.getContext("2d");
  101 |             // Create axes
> 102 |             new Chart(ctx, {
      |                 ^
  103 |                 type: 'horizontalBar',
  104 |                 data: {
  105 |                     labels: labels,

error: Duplicate key 'ticks' (no-dupe-keys) at src/components/page/FinancialSummary/FinancialChart.vue:139:29:
  137 |                                 scaleInstance.height = 270; 
  138 |                             },
> 139 |                             ticks: {
      |                             ^
  140 |                                 callback: function(value, index, values) {
  141 |                                     return value + '%';
  142 |                                 }

error: 'index' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:140:59:
  138 |                             },
  139 |                             ticks: {
> 140 |                                 callback: function(value, index, values) {
      |                                                           ^
  141 |                                     return value + '%';
  142 |                                 }
  143 |                             }

error: 'values' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:140:66:
  138 |                             },
  139 |                             ticks: {
> 140 |                                 callback: function(value, index, values) {
      |                                                                  ^
  141 |                                     return value + '%';
  142 |                                 }
  143 |                             }

error: Duplicate key 'tooltips' (no-dupe-keys) at src/components/page/FinancialSummary/FinancialChart.vue:158:21:
  156 |                         }]
  157 |                     },
> 158 |                     tooltips : {
      |                     ^
  159 |                         enabled : true,
  160 |                         callbacks: {
  161 |                             label: function(tooltipItem) {

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:175:29:
  173 |                             ctx.font = "10px Open Sans";
  174 |                             ctx.fillStyle = "#313131";
> 175 |                             Chart.helpers.each(
      |                             ^
  176 |                                 this.data.datasets.forEach(function(dataset, i) {
  177 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
  178 |                                 Chart.helpers.each(

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:178:33:
  176 |                                 this.data.datasets.forEach(function(dataset, i) {
  177 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
> 178 |                                 Chart.helpers.each(
      |                                 ^
  179 |                                     meta.data.forEach(function(bar, index) {
  180 |                                     var data = dataset.data[index];
  181 |                                         if (data > 0 ) {

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:219:17:
  217 |             })
  218 |             var ctx = chart.getContext("2d");
> 219 |             new Chart(ctx, {
      |                 ^
  220 |                 type: 'bar',
  221 |                 data: {
  222 |                     labels: labels,

error: 'index' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:283:59:
  281 |                             ticks: {
  282 |                                     // Include a dollar sign in the ticks
> 283 |                                 callback: function(value, index, values) {
      |                                                           ^
  284 |                                     if (value < 0 ) return null;
  285 |                                     return '$' + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  286 |                                 },

error: 'values' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:283:66:
  281 |                             ticks: {
  282 |                                     // Include a dollar sign in the ticks
> 283 |                                 callback: function(value, index, values) {
      |                                                                  ^
  284 |                                     if (value < 0 ) return null;
  285 |                                     return '$' + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  286 |                                 },

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:323:29:
  321 |                             ctx.fillStyle = "#8E8F93";
  322 | 
> 323 |                             Chart.helpers.each(
      |                             ^
  324 |                                 this.data.datasets.forEach(function(dataset, i) {
  325 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
  326 |                                 Chart.helpers.each(

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:326:33:
  324 |                                 this.data.datasets.forEach(function(dataset, i) {
  325 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
> 326 |                                 Chart.helpers.each(
      |                                 ^
  327 |                                     meta.data.forEach(function(bar, index) {
  328 |                                     var data = dataset.data[index];
  329 |                                         if (data > 0 ) {

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:357:17:
  355 |             })
  356 |             var ctx = chart.getContext("2d");
> 357 |             new Chart(ctx, {
      |                 ^
  358 |                 type: 'bar',
  359 |                 data: {
  360 |                     labels: labels,

error: 'index' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:420:59:
  418 |                             ticks: {
  419 |                                     // Include a dollar sign in the ticks
> 420 |                                 callback: function(value, index, values) {
      |                                                           ^
  421 |                                     if (value < 0 ) return null;
  422 |                                     return '$' + value + 'M';
  423 |                                 }

error: 'values' is defined but never used (no-unused-vars) at src/components/page/FinancialSummary/FinancialChart.vue:420:66:
  418 |                             ticks: {
  419 |                                     // Include a dollar sign in the ticks
> 420 |                                 callback: function(value, index, values) {
      |                                                                  ^
  421 |                                     if (value < 0 ) return null;
  422 |                                     return '$' + value + 'M';
  423 |                                 }

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:459:29:
  457 |                             ctx.fillStyle = "#8E8F93";
  458 | 
> 459 |                             Chart.helpers.each(
      |                             ^
  460 |                                 this.data.datasets.forEach(function(dataset, i) {
  461 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
  462 |                                 Chart.helpers.each(

error: 'Chart' is not defined (no-undef) at src/components/page/FinancialSummary/FinancialChart.vue:462:33:
  460 |                                 this.data.datasets.forEach(function(dataset, i) {
  461 |                                     var meta = chartInstance.controller.getDatasetMeta(i);
> 462 |                                 Chart.helpers.each(
      |                                 ^
  463 |                                     meta.data.forEach(function(bar, index) {
  464 |                                     var data = dataset.data[index];
  465 |                                         if (data > 0 ) {

18 errors found.

Module Warning (from ./node_modules/eslint-loader/index.js):
error: Empty block statement (no-empty) at src/components/page/FarmStress/FarmStress.vue:145:34:
  143 |                     i ++;
  144 |                 })
> 145 |                 if ( index == 1) {
      |                                  ^
  146 |                     
  147 |                 } else {
  148 |                     res = (res / i).toFixed(2)

error: 'ref' is assigned a value but never used (no-unused-vars) at src/components/page/FarmStress/FarmStress.vue:162:21:
  160 |             CreateStressN (index) {
  161 |                 var self = this;
> 162 |                 var ref = '';
      |                     ^
  163 |                 let chart = '';
  164 |                 this.location.fill(0)
  165 | 

error: 'maxium' is already defined (no-redeclare) at src/components/page/FarmStress/FarmStress.vue:209:29:
  207 |                         var maxium = this.WholeResultAcre(5) > this.WholeResultAcre(2) ? this.WholeResultAcre(5) : this.WholeResultAcre(2) * 1.15; 
  208 |                     } else {
> 209 |                         var maxium = this.ProjectedRevenue > this.$store.state.CostProduction ? this.ProjectedRevenue : this.$store.state.CostProduction * 1.15; 
      |                             ^
  210 |                     }
  211 |                 } else {
  212 |                     if ((this.isPerAcre || this.isperAcre_Print)) {

error: 'maxium' is already defined (no-redeclare) at src/components/page/FarmStress/FarmStress.vue:213:29:
  211 |                 } else {
  212 |                     if ((this.isPerAcre || this.isperAcre_Print)) {
> 213 |                         var maxium = this.$store.state.financialDataPerAcre[this.pick][5] * 1.15 > this.$store.state.financialDataPerAcre[this.pick][2] ? this.$store.state.financialDataPerAcre[this.pick][5] * 1.15 : this.$store.state.financialDataPerAcre[this.pick][2] * 1.1
      |                             ^
  214 |                     } else {
  215 |                         var maxium = ((this.Analy_data.irrigated[3] + this.Analy_data.dry[3]) * 1.15 > (this.Analy_data.dry[4] + this.Analy_data.irrigated[4])) ? (this.Analy_data.irrigated[3] + this.Analy_data.dry[3]) * 1.15 : (this.Analy_data.dry[4] + this.Analy_data.irrigated[4]) * 1.15;
  216 |                     }

error: 'maxium' is already defined (no-redeclare) at src/components/page/FarmStress/FarmStress.vue:215:29:
  213 |                         var maxium = this.$store.state.financialDataPerAcre[this.pick][5] * 1.15 > this.$store.state.financialDataPerAcre[this.pick][2] ? this.$store.state.financialDataPerAcre[this.pick][5] * 1.15 : this.$store.state.financialDataPerAcre[this.pick][2] * 1.1
  214 |                     } else {
> 215 |                         var maxium = ((this.Analy_data.irrigated[3] + this.Analy_data.dry[3]) * 1.15 > (this.Analy_data.dry[4] + this.Analy_data.irrigated[4])) ? (this.Analy_data.irrigated[3] + this.Analy_data.dry[3]) * 1.15 : (this.Analy_data.dry[4] + this.Analy_data.irrigated[4]) * 1.15;
      |                             ^
  216 |                     }
  217 |                 }
  218 |                 var ctx = chart.getContext("2d");

error: 'Chart' is not defined (no-undef) at src/components/page/FarmStress/FarmStress.vue:220:36:
  218 |                 var ctx = chart.getContext("2d");
  219 |                 // if (this.myChart) this.myChart.clear();
> 220 |                 this.mychart = new Chart(ctx, {
      |                                    ^
  221 |                     type: 'bar',
  222 |                     data: {
  223 |                         labels: categories,

error: 'value' is defined but never used (no-unused-vars) at src/components/page/FarmStress/FarmStress.vue:272:56:
  270 |                                 },
  271 |                                 ticks : {
> 272 |                                     callback: function(value, index, values) {
      |                                                        ^
  273 |                                         return null
  274 |                                     },
  275 |                                     beginAtZero: true,

error: 'index' is defined but never used (no-unused-vars) at src/components/page/FarmStress/FarmStress.vue:272:63:
  270 |                                 },
  271 |                                 ticks : {
> 272 |                                     callback: function(value, index, values) {
      |                                                               ^
  273 |                                         return null
  274 |                                     },
  275 |                                     beginAtZero: true,

error: 'values' is defined but never used (no-unused-vars) at src/components/page/FarmStress/FarmStress.vue:272:70:
  270 |                                 },
  271 |                                 ticks : {
> 272 |                                     callback: function(value, index, values) {
      |                                                                      ^
  273 |                                         return null
  274 |                                     },
  275 |                                     beginAtZero: true,

error: 'Chart' is not defined (no-undef) at src/components/page/FarmStress/FarmStress.vue:306:33:
  304 |                                 var ctx = chartInstance.ctx;
  305 |                                 ctx.font = "bold 10.5px Open Sans";
> 306 |                                 Chart.helpers.each(
      |                                 ^
  307 |                                     this.data.datasets.forEach(function(dataset, i) {
  308 |                                         var meta = chartInstance.controller.getDatasetMeta(i);
  309 |                                     Chart.helpers.each( 

error: 'Chart' is not defined (no-undef) at src/components/page/FarmStress/FarmStress.vue:309:37:
  307 |                                     this.data.datasets.forEach(function(dataset, i) {
  308 |                                         var meta = chartInstance.controller.getDatasetMeta(i);
> 309 |                                     Chart.helpers.each( 
      |                                     ^
  310 |                                         meta.data.forEach(function(bar, ind) {
  311 |                                             var data = dataset.data[ind];
  312 |                                             if ( i == 0 ) {

11 errors found.

Module Warning (from ./node_modules/eslint-loader/index.js):
error: Empty block statement (no-empty) at src/components/page/FinancialSummary/FinancialSummary.vue:170:34:
  168 |                     i ++;
  169 |                 })
> 170 |                 if ( index == 1) {
      |                                  ^
  171 |                     
  172 |                 } else if ( index == 2 ) {
  173 |                     res = (res / i).toFixed(2)

我发出一些中间日志,因为它太长了,张贴在这里。

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:385:21:
  383 |                 case 2 :
  384 |                     return formatNumber(data.irrigated[4])
> 385 |                     break;
      |                     ^
  386 |                 case 3:
  387 |                     return formatNumber((data.irrigated[4] + data.dry[4]));
  388 |                     break;

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:388:21:
  386 |                 case 3:
  387 |                     return formatNumber((data.irrigated[4] + data.dry[4]));
> 388 |                     break;
      |                     ^
  389 |             }
  390 |         },
  391 |         CalculateCost_Acre(cate, data) {

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:398:21:
  396 |                 case 1 :
  397 |                     return formatNumber((data.dry[5]).toFixed(2))
> 398 |                     break;
      |                     ^
  399 |                 case 2 :
  400 |                     return formatNumber((data.irrigated[5]).toFixed(2))
  401 |                     break;

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:401:21:
  399 |                 case 2 :
  400 |                     return formatNumber((data.irrigated[5]).toFixed(2))
> 401 |                     break;
      |                     ^
  402 |                 case 3:
  403 |                     return formatNumber(((data.irrigated[4] + data.dry[4]) / (data.irrigated[0] + data.dry[0])).toFixed(2));
  404 |                     break;

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:404:21:
  402 |                 case 3:
  403 |                     return formatNumber(((data.irrigated[4] + data.dry[4]) / (data.irrigated[0] + data.dry[0])).toFixed(2));
> 404 |                     break;
      |                     ^
  405 |             }
  406 |         },
  407 |         CalculateCost_Yield(cate, data, fluctuation) {

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:414:21:
  412 |                 case 1 :
  413 |                     return formatNumber((data.dry[4] / (data.dry[2] * fluctuation)).toFixed(2))
> 414 |                     break;
      |                     ^
  415 |                 case 2 :
  416 |                     return formatNumber((data.irrigated[4] / (data.irrigated[2] * fluctuation)).toFixed(2))
  417 |                     break;

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:417:21:
  415 |                 case 2 :
  416 |                     return formatNumber((data.irrigated[4] / (data.irrigated[2] * fluctuation)).toFixed(2))
> 417 |                     break;
      |                     ^
  418 |                 case 3:
  419 |                     return formatNumber(((data.irrigated[4] + data.dry[4]) / ((data.irrigated[2] + data.dry[2]) * fluctuation)).toFixed(2));
  420 |                     break;

error: Unreachable code (no-unreachable) at src/components/page/CropAnalysis/CropAnalysis.vue:420:21:
  418 |                 case 3:
  419 |                     return formatNumber(((data.irrigated[4] + data.dry[4]) / ((data.irrigated[2] + data.dry[2]) * fluctuation)).toFixed(2));
> 420 |                     break;
      |                     ^
  421 |             }
  422 |         },
  423 |         CalculatePrice (priceFluctuate) {

22 errors found.

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
 warning  in ./src/main.js

"export 'default' (imported as 'myFunc') was not found in './assets/js/function.js'

  App running at:
  - Local:   http://localhost:8080 
  - Network: http://192.168.0.15:8080

  Note that the development build is not optimized.
  To create a production build, run npm run build.

package.json

{
  "name": "crop_analysis",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:e2e": "vue-cli-service test:e2e",
    "test:unit": "vue-cli-service test:unit",
    "start": "nodemon watch server.js"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "bootstrap": "^4.4.1",
    "bootstrap-vue": "^2.4.0",
    "chart.js": "^2.9.3",
    "chartjs-plugin-labels": "^1.1.0",
    "core-js": "^2.6.11",
    "extract-text-webpack-plugin": "^3.0.2",
    "hchs-vue-charts": "^1.2.8",
    "jest": "^21.2.0",
    "jest-serializer-vue": "^0.3.0",
    "jquery": "^3.4.1",
    "nightwatch": "^0.9.12",
    "node-notifier": "^5.1.2",
    "nodemon": "^1.19.4",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "popper": "^1.0.1",
    "popper.js": "^1.16.1",
    "portfinder": "^1.0.25",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "rimraf": "^2.6.0",
    "selenium-server": "^3.0.1",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "sync-exec": "^0.6.2",
    "vue": "^2.6.11",
    "vue-custom-element": "^3.2.12",
    "vue-html-to-paper": "^1.3.0",
    "vue-print-nb": "^1.5.0",
    "vue-print-nb-jeecg": "^1.0.9",
    "vue-property-decorator": "^6.0.0",
    "vue-resource": "^1.3.4",
    "vue-style-loader": "^3.0.1",
    "vuex": "^3.1.2"
  },
  "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/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "file-loader": "^4.3.0",
    "html-webpack-plugin": "^3.2.0",
    "lint-staged": "^8.1.5",
    "node-sass": "^4.13.1",
    "sass-loader": "^7.1.0",
    "ttf-loader": "^1.0.2",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "overrides": [
      {
        "files": [
          "**/__tests__/*.{j,t}s?(x)"
        ],
        "env": {
          "jest": true
        }
      }
    ]
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  }
}
eivgtgni

eivgtgni1#

你的朋友没有使用Eslint或者他忽略了它。你也可以忽略它。
转到你的应用程序的根目录。应该有一个vue.config.js文件,如果没有任何文件,请创建一个。
要停用eslint写入:

module.exports = {
    lintOnSave: false
 }

现在停止你的应用程序并使用npm run serve重新启动它,你现在不应该看到任何eslint错误。
这些都不是“真实的的”错误,它只是,怎么说,“美丽”的错误,他没有遵循最佳实践如何编写干净的代码。

相关问题