Tag Archives: View – cli

Solution of “do not use ‘new’ for side effects” for eslint verification of Vue project

When I was writing Vue project, I wrote the following code in JS to report an error

import Vue from 'vue'
import App from './App.vue'

new Vue({
  el: '#app',
  component: {
    App
  },
  template: '<App/>'
})

Solution:

1. Define a variable XXX to accept the created Vue, and then add XXX to use

import Vue from 'vue'
import App from './App.vue'

let myOwn = new Vue({
  el: '#app',
  component: {
    App
  },
  template: '<App/>'
})
Vue.use ({ xxx })

2. Add a comment line above the new Vue so that eslint does not check for ‘no new’

import Vue from 'vue'
import App from './App.vue'

/* eslint-disable no-new */
new Vue({
  el: '#app',
  component: {
    App
  },
  template: '<App/>'
})

 

Create vue-cli4 project and report error command failed: yarn

Error command failed: yard

Solution 1: enter CMD in Win + R to enter the command line interface

Input command

npm install -g yarn

After success, re create the vue-cli4 project to solve the problem.

Solution 2:

Enter the C/users/administrator/Windows environment

There is a file. Vuerc

Open this file to show

{
  "useTaobaoRegistry": true,
  "packageManager": "yarn"
}

Just manually change the configuration content yarn to NPM to change the package manager when creating the project

 

Solution 3:

Delete the. Vuerc file. When creating a Vue project for the first time, you will be prompted to select configuration, and then you can select NPM.