npm run serve get stuck on 40% while running - vue.js

It’s been a couple of weeks that I’m working on a Vue js project Vuetify to be specific. I use npm run serve command to build and run a live server. it was working fine everything was okay but suddenly I run my project again and boom can’t building anymore it gets stuck 40% without throwing anything as a bug or an error. I wanna know guys if you had similar issue like mine or if you know how to troubleshoot this issue. thank in advance.
I'm using npm 6.9.0 , node v10.16.0 and vue 3.9.2
package.json
{
"name": "mycode",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5",
"fuse.js": "^3.4.5",
"moment": "^2.24.0",
"vue": "^2.6.10",
"vue-axios": "^2.1.4",
"vue-i18n": "^8.12.0",
"vue-router": "^3.0.3",
"vue-table-component": "^1.9.2",
"vuelidate": "^0.7.4",
"vuetify": "^1.5.5"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^3.9.0",
"#vue/cli-plugin-eslint": "^3.9.0",
"#vue/cli-service": "^3.9.3",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"live-server": "^1.2.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"typescript": "^3.5.3",
"vue-cli-plugin-vuetify": "^0.5.0",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.3.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

Sometimes during the compiling process certain errors occur. For example say I have a component with a template that contains the following
<template>
<imagingheader></imagingheader>
<router-view ></router-view>
</template>
Now what is wrong with this picture?
There are two base elements in the template. During the compiling process this will prevent it from going any further and sadly the server does not start to display this error. Moving the two elements into a common div tag fixes the issue and moves the compling process from 40% to 100%.

Take some time and look through your code and see whether you will get a missing closing tag. It can be a missing , , ... etc.
Keep an eye on the first place the numbers pause and use that as a way to narrow down the problems you might face.
40% building 223/268 modules 45 active ...rders\List.vue?

I just ended up wasting 30 minutes on a similar issue, to find out that I had a merge (due to git pull) in progress and there were conflicted filed :/

Related

Failed to load config "eslint-plugin-vue" to extend from

I am setting up eslint for vue in vscode. I am getting this notification when ever I format my code.
ESLint stack trace:
[Error - 2:20:56 AM] Error: Failed to load config "eslint-plugin-vue" to extend from.
Referenced from: C:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\package.json
at configMissingError (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:265:9)
at ConfigArrayFactory._loadExtendedShareableConfig (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:826:23)
at ConfigArrayFactory._loadExtends (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:731:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:660:25)
at _normalizeObjectConfigDataBody.next (<anonymous>)
at ConfigArrayFactory._normalizeObjectConfigData (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:596:20)
at _normalizeObjectConfigData.next (<anonymous>)
at createConfigArray (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:340:25)
at ConfigArrayFactory.loadInDirectory (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\config-array-factory.js:433:16)
at CascadingConfigArrayFactory._loadConfigInAncestors (c:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:328:46)
my package.json file :-
{
"name": "vue-eslint-truth",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/recommended",
"eslint:recommended",
"prettier",
"eslint-plugin-vue"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
I am new to vue js and I don't know what to do to make the eslint work correctly. When I try to run the vue app using npm run serve, the development server just don't start and gives me this error that
Syntax Error: Error: Failed to load config "eslint-plugin-vue" to extend from.
Referenced from: C:\Users\dell\Desktop\Web current Projects\Vue.Js\vue-eslint-truth\package.json
at _normalizeObjectConfigDataBody.next (<anonymous>)
at _normalizeObjectConfigData.next (<anonymous>)
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.
You don't need to extend eslint-plugin-vue on your eslintConfig of you packages.json. As you can see on documentation.

Vue quaser production build "A web page is slowing down your browser"

I'm building a web application with Vue and Quaser. My development environment works fine and everything loads as it should. I serve the development like any other:
npm run serve
However, on a build, the application takes a lot of resources and freezes the browser. I get the message "A web page is slowing down your browser" on firefox while chrome based browsers simply take a lot of time.
npm run build
serve -s dist
I used serve -s dist to test wh netlify was not loading locally. I cannot seem to get why this happens. My package.json looks is as below:
{
"name": "friendly-chainsaw-sass-kit",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#quasar/extras": "^1.0.0",
"apexcharts": "^3.26.0",
"core-js": "^3.6.5",
"quasar": "^1.0.0",
"vue": "^2.6.11",
"vue-apexcharts": "^1.6.0",
"vue-css-donut-chart": "^1.3.0",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-unit-jest": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/composition-api": "^1.0.0-rc.5",
"#vue/eslint-config-prettier": "^6.0.0",
"#vue/test-utils": "^1.0.3",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"prettier": "^1.19.1",
"vue-cli-plugin-quasar": "~3.0.1",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"#vue/prettier"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {},
"overrides": [
{
"files": [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)"
],
"env": {
"jest": true
}
}
]
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"jest": {
"preset": "#vue/cli-plugin-unit-jest"
}
}
Is there something I might be doing wrong?
As #larizzatg alluded, the error from such a message came from a race condition, just that there was no clear concise error message or direction I could get to from the pop-up. In one of my components, I had a for loop, wherein I was slicing.
<div v-for="task in allTasks.splice(0,3)" :key="task.name">
The above would have looped through the array of tasks, just not all of them, 3 items to be exact. It works fine in development. However, to get around the error.
<div v-for="task in topTasks" :key="task.name">
Where topTasks comes from a computed property. This should have just failed during the development phase other than giving hope it works. I have done the same implementation with Angular-based applications just fine. I hadn't thought it would be an issue with Vue. Makes you go through your previous code implementations to wonder.

Broken image in dist package of vue application with webpack

I have a vue application with single file components, and I'm using webpack. One of the components has an image that works fine locally when I run it with npm run serve, but when I build the application (using npm run build) and deploy it online, I just see the broken image icon.
The image is is referenced in this in the component:
<img id="sockPhoto" :src="require('../assets/a_sock.png').default" alt="a_sock">
but if I inspect the same element in the deployed version, I see this:
<img data-v-f9e5c994="" id="sockPhoto" alt="a_sock">
which doesn't even have a src attribute.
This is the relevant part of my package.json:
{
"name": "my-app ",
"version": "0.2.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test": "jest"
},
"dependencies": {
"bootstrap": "^4.5.0",
"bootstrap-vue": "^2.15.0",
"core-js": "^3.6.5",
"file-loader": "^6.0.0",
"jquery": "^3.5.1",
"jspdf": "^1.5.3",
"popper.js": "^1.16.1",
"portal-vue": "^2.1.7",
"printd": "^1.4.2",
"vue": "^2.6.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.3.1",
"#vue/cli-plugin-eslint": "^4.3.1",
"#vue/cli-service": "^4.4.1",
"#vue/test-utils": "^1.0.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"jest": "^26.0.1",
"vue-jest": "^3.0.5",
"vue-template-compiler": "^2.6.11",
"vue-test-utils": "^1.0.0-beta.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"browserslist": [
"> 1%",
"last 2 versions"
],
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"transform": {
"^[^.]+.vue$": "vue-jest",
"^.+\\.js$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
}
}
Also, this was working before my latest deployment, which contained some modifications, but nothing I can think of that should mess this up.
I am relatively new to vue and webpack so all help is much appreciated.
EDIT: I have already tried the basic <img id="sockPhoto" src="./../assets/36_37.png" alt="a_sock">, but that didn't even work locally. This answer provided me with the method above, using require(...).default which was working fine until this last deployment.

Vue CLI 3 app not loading in IE with some npm packages

I have created a Vue app with vue-cli 3. It was working fine in all browsers until I installed a npm package "microsoft-cognitiveservices-speech-sdk". To my knowledge, I guess, this particular package is not getting transpiled by babel. Below is my babel.config.js and package.json
//babel.config.js
module.exports = {
presets: [
'#vue/app'
]
}
//package.json
{
"name": "vueApp",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5",
"microsoft-cognitiveservices-speech-sdk": "^1.7.0",
"vue": "^2.6.10",
"vue-good-table": "^2.18.0",
"vue-i18n": "^8.14.0",
"vue-router": "^3.1.2",
"vue-uuid": "^1.1.1",
"vuex": "^3.1.1"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^3.10.0",
"#vue/cli-plugin-eslint": "^3.10.0",
"#vue/cli-service": "^3.10.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"http-proxy-middleware": "^0.20.0",
"less": "^3.10.2",
"less-loader": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
Once I installed the package, my application is not loading in IE (version 11) browser. But works like a charm in Google Chrome.
Can anyone help me out to solve this problem? Thanks in advance!
After a huge research and tried out the suggestions in the web, I have fixed the issue. So apparently, you need to create a configuration file for the app to transpile your troubling packages.
Create a vue.config.js in your root directory and add a property transplieDependencies, an array to contain your troubled libraries for es5 conversion.
//vue.config.js
module.exports = {
transplieDependencies: [
"your trouble library name"
]
}
Once you implemented the above changes, restart your server to get it working in IE.

Vue Babel outputting incompatible code disregarding browserslist

I have a Vue CLI 3 project that I am building. The built code seems to disregard broswerslist. It outputs code that breaks Microsoft Edge regardless if I add Edge to browserslist or not.
The syntax that is being output is the parameter spread operator in a lambda like
(...x) => {}
This is unsupported by a certain version of Edge, and my project keeps outputting it !
These are some of my files:
package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"await-mutex": "^1.0.2",
"axios": "^0.18.0",
"bootstrap": "^4.3.1",
"bootstrap-vue": "^2.0.0-rc.15",
"json5-loader": "^1.0.1",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.11",
"popper.js": "^1.14.7",
"pretty-checkbox-vue": "^1.1.9",
"vee-validate": "^2.2.0",
"vue": "^2.6.9",
"vue-router": "^3.0.2",
"vuex": "^3.1.0",
"tiptap": "^1.14.0"
},
"devDependencies": {
"#types/lodash": "^4.14.123",
"#vue/cli-plugin-babel": "^3.5.1",
"#vue/cli-plugin-eslint": "^3.5.1",
"#vue/cli-plugin-typescript": "^3.5.1",
"#vue/cli-service": "^3.5.1",
"#vue/eslint-config-typescript": "^3.0.5",
"#types/jwt-decode": "^2.2.1",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.1",
"typescript": "^3.0.0",
"vue-template-compiler": "^2.6.9"
}
}
.browserslistrc
> 1%
last 2 versions
edge 15
not ie <= 8
babel.config.js
module.exports = {
presets: [
'#vue/app',
],
}
What I have tried:
Removing Typescript from project
Changing .browserslistrc with invalid browser to check if it's reading the file or not, and the build crashed because of browser not found (means it's reading the file).
Settings .browserslistrc to "ie 11", and it still outputs lambdas and spread operators.
The problem lies in two things combined.
Babel (at least by default) doesn't transpile imported libraries, hence any imported JS file that uses new syntax has a great chance it is kept as-is.
Bootstrap-Vue uses such syntax, and importing individual components can cause this problem.
Solution:
Import the whole of Bootstrap-Vue and Vue.use it in main.js