[Exception] When Jenkins executes the Npm build of the front-end project, an error occurs This dependency was not found: vue-class-component in ./node_modules/vu

1. Error screenshot

The colleague's code changes, resulting in the inability to execute the build in Jenkins
insert image description here

13:50:30   WARN  A new version of sass-loader is available. Please upgrade for best experience.
13:50:31  TypeError: Cannot set property mark of #<Object> which has only a getter
13:50:31  TypeError: Cannot set property mark of #<Object> which has only a getter
13:50:31      at Object.connectTypeScriptPerformance (/data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/typescript-reporter/profile/TypeScriptPerformance.js:12:36)
13:50:31      at createTypeScriptReporter (/data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/typescript-reporter/reporter/TypeScriptReporter.js:36:49)
13:50:31      at Object.<anonymous> (/data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/reporter/reporter-rpc/ReporterRpcService.js:20:30)
13:50:31      at Generator.next (<anonymous>)
13:50:31      at /data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/reporter/reporter-rpc/ReporterRpcService.js:8:71
13:50:31      at new Promise (<anonymous>)
13:50:31      at __awaiter (/data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/reporter/reporter-rpc/ReporterRpcService.js:4:12)
13:50:31      at /data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/reporter/reporter-rpc/ReporterRpcService.js:18:88
13:50:31      at Object.<anonymous> (/data/jenkins/jenkins/workspace/xxx/node_modules/fork-ts-checker-webpack-plugin-v5/lib/rpc/RpcService.js:23:38)
13:50:31      at Generator.next (<anonymous>)
13:50:58   ERROR  Failed to compile with 2 errors1:50:56 PM
13:50:58  
13:50:58  This dependency was not found:
13:50:58  
13:50:58  * vue-class-component in ./node_modules/vue-property-decorator/lib/index.js, ./node_modules/vue-property-decorator/lib/decorators/Watch.js
13:50:58  
13:50:58  To install it, you can run: npm install --save vue-class-component
13:50:58   ERROR  Build failed with errors.
13:50:58  npm ERR! code ELIFECYCLE
13:50:58  npm ERR! errno 1
13:50:58  npm ERR! [email protected] build: `vue-cli-service build --mode prod`
13:50:58  npm ERR! Exit status 1
13:50:58  npm ERR! 
13:50:58  npm ERR! Failed at the [email protected] build script.
13:50:58  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
13:50:58  
13:50:58  npm ERR! A complete log of this run can be found in:
13:50:58  npm ERR!     /data/jenkins/.npm/_logs/2023-04-19T05_50_56_890Z-debug.log

2. Error description

The reason for the error is that the vue-class-component was introduced in the project, but it was not found in the project's dependency list, so the above error will be reported.

2.1 Introduction to vue-class-component

vue-class-component is a TypeScript decorator for classy Vue components.
It allows you to define Vue components as classes, which can make your code more organized and easier to read.
It also provides other decorators for defining computed properties, observers, and event handlers.

official document

2.2 Using vue-class-component

To use vue-class-component, you first need to install it via npm:

npm install vue-class-component

Once installed, you can import it in your Vue component file and define the component as a class using the @Component decorator:

import {
    
     Component, Vue } from 'vue-class-component';

@Component
export default class MyComponent extends Vue {
    
    
  // 组件逻辑在这里
}

You can then define your component's data, methods, and lifecycle hooks as class properties and methods:

@Component
export default class MyComponent extends Vue {
    
    
  // 数据
  message: string = 'Hello, world!';

  // 方法
  onClick(): void {
    
    
    console.log('Button clicked!');
  }

  // 生命周期钩子
  mounted(): void {
    
    
    console.log('Component mounted!');
  }
}

Three, error resolution

Just introduce vue-class-component, and re-execute the Jenkins build, that is, try to build again, the problem is solved!
insert image description here

Guess you like

Origin blog.csdn.net/wstever/article/details/130246369
Recommended