We have a whole network of projects, more than 15 projects, each of them has been working for more than three years. Today, suddenly after reinstalling node modules, an error appeared everywhere:
Syntax Error: Error: C:\Users\veneg\Desktop\***\assets2\src\views\template\Socials.vue:2:1
1|
> 2| .social
-------^
3| a.social__link.rtl(v-for="(soc, index) in socials" :key="index" :href="soc.link" target="blank")
4| icon(:name="soc.name" nofill)
5|
unexpected token "indent"
There are over 3000 files in the project with this error, how can I fix this?
I tried to play with pug loader versions but nothing helped.
My versions:
"vue-loader": "~15.6",
"vue-style-loader": "~4.1",
"vue-template-compiler": "~2.6",
"webpack": "~4.29",
"webpack-bundle-analyzer": "~3.0",
"webpack-cli": "~3.2",
"webpack-dev-server": "~3.1",
"webpack-hot-middleware": "~2.24",
"webpack-merge": "~4.2"
"#vue/cli-plugin-babel": "4.2.0",
"#vue/cli-plugin-eslint": "4.2.0",
"#vue/cli-service": "4.4.1",
"#vue/eslint-config-airbnb": "5.0.2",
"pug": "2.0.4",
"pug-plain-loader": "1.0.0",
Instead of the pug-plain-loader try to use the #webdiscus/pug-loader.
This loader support the indent in Vue template:
<template lang='pug'>
h1 Hello Pug!
p Text
</template>
See how to use Pug loader with Vue and source of example.
Related
I am trying to run a unit test in a Vue 2.6 app (needs to stay 2.6) with Mocha + Chai. Running dummy tests (eg. expect(1 + 1).to.equal(2)) works ok.
However, when I try mounting a Vue component inside the test file, it fails like so:
<template>
^
SyntaxError: Unexpected token '<'
So I guess I am missing something in my Mocha setup to resolve .vue files properly.
In my .mocharc.yaml I have just this:
require: [
'#babel/register'
]
and my dev dependencies are:
"devDependencies": {
"#babel/cli": "^7.19.3",
"#babel/core": "^7.19.3",
"#babel/preset-env": "^7.19.3",
"#babel/register": "^7.18.9",
"#vue/cli-plugin-babel": "5.0.0",
"#vue/cli-plugin-unit-mocha": "~5.0.0",
"#vue/composition-api": "^1.7.1",
"#vue/test-utils": "1.3.0",
"chai": "4.2.0",
"eslint": "8.15.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-n": "15.2.0",
"eslint-plugin-promise": "6.0.0",
"husky": "8.0.0",
"mocha": "8.4.0",
"nx": "14.8.2",
"vue-template-compiler": "2.6.14"
},
Any ideas what to add?
It was under my understanding that Vue 3 got rid of one-container restriction in template and the mandatory v-bind:key in v-for loops. But my code gives errors. i.e.:
"Component template should contain exactly one root element."
fyi I use vue-3 in combination with Nuxt... maybe that changes things.
Here is my package.json stack:
"dependencies": {
"#nuxtjs/axios": "^5.13.1",
"#nuxtjs/composition-api": "^0.24.4",
"core-js": "^3.9.1",
"nuxt": "^2.15.3"
},
"devDependencies": {
"#nuxt/types": "^2.15.3",
"#nuxt/typescript-build": "^2.1.0",
"#nuxtjs/eslint-config-typescript": "^6.0.0",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/vuetify": "^1.12.1",
"#vue/test-utils": "^1.1.3",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"eslint": "^7.22.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-vue": "^7.7.0",
"jest": "^26.6.3",
"ts-jest": "^26.5.4",
"vue-jest": "^3.0.4"
}
The dependencies says I have Linting but this is not actively running..
Anyone knows what is going on?
Nuxt is only compatible with Vue2 as lf right now. Even if you use #nuxtjs/composition-api, this will not change the way the template is compiled (it is still Vue2 at the end of the loop).
The latter package only enables the use of composition API, this is not actually Vue3.
I have an Vuejs App using promise but get this error :
This dependency was not found: core-js/fn/promise in ./src/store/index.js To install it, you can run: npm install --save core-js/fn/promise
my package.json:
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.5.3",
"core-js": "^3.6.5",
"jquery": "^3.5.1",
"popper.js": "^1.16.1",
"vue": "^2.6.11",
"vue-axios": "^3.2.2",
"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-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
I run the command npm install --save core-js/fn/promise ,but nothing change
I have the same err today, reason is import { reject } from "core-js/fn/promise",
I delete it then app compiled successfully.
Try update your core-js dependency version by:
npm install core-js
// or
yarn add core-js
The error is a result of yourProject/node_modules/core-js is not sync with your code.
You're importing core-js/fn/promise, but the build tool not found it.
I had a similar problem with core-js when I tried to start a Vue app, this was the error:
core-js/modules/es6.array.find in ./src/state/helpers.js,
* core-js/modules/es6.function.name in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/_base-link.vue?vue&type=script&lang=js&, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/_base-icon.vue?vue&type=script&lang=js& and 4 others
...
..
..
my fix was to update dependencies and my package.json after the update is the next:
{
...
"dependencies": {
"core-js": "^2.6.12",
"vue": "2.5.16"
},
"devDependencies": {
"#babel/core": "^7.14.6",
}
}
Do the following steps:
npm install name dependency,
npm install
It's perfectly running for me.
We've been pushing updates successfully to our Vue applications in recent weeks and after some very minimal changes yesterday (property name changes and removing some purely semantic characters) we are experiencing the following error:
Uncaught TypeError: Object(...) is not a function
at Module.fae3 (XCustomerServiceOptionsLibrary.umd.js:53612)
at n (XCustomerServiceOptionsLibrary.umd.js:30)
at 0012 (XCustomerServiceOptionsLibrary.umd.js:94)
at XCustomerServiceOptionsLibrary.umd.js:11
at XCustomerServiceOptionsLibrary.umd.js:3
at Object.e977 (XCustomerServiceOptionsLibrary.umd.js:1)
at o (app.2df3392d.js:formatted:39)
at CustomerServiceManagement.umd.js:3
at Object.7091 (CustomerServiceManagement.umd.js:1)
at o (app.2df3392d.js:formatted:39)
We debugged the code and found the error occurring on this line:
const _withId = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withScopeId"])("data-v-569a422e")
We build Vue components into libraries, push them to a Verdaccio repo, and then add them as dependencies into a larger project. The library in questions (XCustomerServiceOptionsLibrary) and the larger Vue application build fine, but produce the above error when serving.
I am starting to think there were a version change to one of our Vue dependencies that is causing issues. Here are our package.json files:
Library
"devDependencies": {
"apollo-boost": "^0.4.4",
"autoprefixer": "^9.6.1",
"graphql": "^14.2.1",
"material-design-icons-iconfont": "^5.0.1",
"moment": "^2.24.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vue": "^2.6.11",
"vue-apollo": "^3.0.0-beta.28",
"vuetify": "^1.5.16",
"vuex": "^3.0.1",
"webpack": "^4.36.1",
"#vue/cli": "^4.1.2",
"#vue/cli-service": "^4.1.2",
"vue-template-compiler": "^2.6.11"
},
App
"apollo-boost": "^0.3.1",
"autoprefixer": "^9.6.1",
"graphql": "^14.2.1",
"material-design-icons-iconfont": "^5.0.1",
"moment": "^2.24.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vue": "^2.6.10",
"vue-apollo": "^3.0.0-beta.28",
"vuetify": "^1.5.16",
"vuex": "^3.0.1",
"webpack": "^4.36.1",
"#vue/cli": "^4.1.2",
"#vue/cli-service": "^4.1.2",
"vue-template-compiler": "^2.6.11"
You need to change your Vue version to Vue3.
Some updates to a dependency of one of our dependencies broke our build and was a bit tricky to find out what the cause of the issue was...
We finally noticed that #vue/component-compiler-utils requires "prettier": "^1.11.1" and - as discussed in vue webpack template missing parser that Prettier#1.13.0 causes the issue we were having, before rolling back to Prettier#1.12.0
How do we ensure that package-lock.json "locks" dependencies to a version and do not update over time or when re-installed?
This is an example of our package.json from which the incorrect lock file is generated:
{
...
"dependencies": {
"html-loader": "0.5.1",
"vue": "2.5.16",
"vue-class-component": "6.2.0",
"vue-property-decorator": "6.1.0",
"vue-router": "3.0.1",
"vuex": "3.0.1",
"vuex-class": "0.3.0",
...
},
"devDependencies": {
"#types/jest": "22.0.1",
"#vue/cli-plugin-babel": "3.0.0-beta.11",
"#vue/cli-plugin-eslint": "3.0.0-beta.11",
"#vue/cli-plugin-typescript": "3.0.0-beta.11",
"#vue/cli-plugin-unit-jest": "3.0.0-beta.7",
"#vue/cli-service": "3.0.0-beta.11",
"#vue/eslint-config-airbnb": "3.0.0-beta.11",
"#vue/eslint-config-typescript": "3.0.0-beta.11",
...
}
}
Using npm shrinkwrap fixes the issue, it converts package-lock.json to a npm-shrinkwrap.json which hashes and locks every specific version installed.
See What is the difference between npm-shrinkwrap.json and package-lock.json? for more details
I'm not entirely sure if npm shrinkwrap fixes the issue in npm v6+.
Here is a snippet of the npm-shrinkwrap.json file that is being generated for vue-loader.
It seems as though even the shrinkwrap is not locking down the requires versions.
"vue-loader": {
"version": "14.0.3",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-14.0.3.tgz",
"integrity": "sha512-5kFK/df1jgVoFcTB9p19rrYcyuYduoZzUSf6chMVsIRmVL9AKPYCa9JGLAZsU1XXGbGO9MSkwbum91u2dx7YcQ==",
"dev": true,
"requires": {
"consolidate": "^0.14.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"lru-cache": "^4.1.1",
"postcss": "^6.0.8",
"postcss-load-config": "^1.1.0",
"postcss-selector-parser": "^2.0.0",
"prettier": "^1.7.0",
"resolve": "^1.4.0",
"source-map": "^0.6.1",
"vue-hot-reload-api": "^2.2.0",
"vue-style-loader": "^4.0.1",
"vue-template-es2015-compiler": "^1.6.0"
}