Trying to create a vue application. The basis of the routing took vue-router. I write the following code in app.js:

import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) import App from './views/App' import Main from './views/Main' const router = new VueRouter({ mode: 'history', routes: [ { path: '/', name: 'main', component: Main }, ], }); const app = new Vue({ el: '#app', components: { App }, router, }); 

And accordingly in the App.vue file:

 <template> <div> <h1>Vue Router Demo App</h1> <p> <router-link :to="{ name: 'main' }">Home</router-link> | </p> <div class="container"> <router-view></router-view> </div> </div> </template> <script> export default {} </script> 

And the main file:

 <template> <p>This is main template/p> </template> 

But when I start the application, I have the following error:

Uncaught Error: Module build failed (from ./node_modules/vue-loader/lib/loaders/templateLoader.js): RangeError: Invalid string length repeat $ 1 (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue -template-compiler / build.js: 4579) at Object.generateCodeFrame (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-template-compiler / build.js: 4561) at loaderContext.emitError.compiled. errors.map (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-loader / lib / loaders / templateLoader.js: 64) at Array.map () at Object.module.exports (: 8080 / home /user/Documents/development/spabrutaltree/node_modules/vue-loader/lib/loaders/templateLoader.js:63) at repeat $ 1 (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-template-compiler / build.js: 4579) at Object.generateCodeFrame (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-template-compiler / build.js: 4561) at loaderC ontext.emitError.compiled.errors.map (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-loader / lib / loaders / templateLoader.js: 64) at Array.map () at Object.module. exports (: 8080 / home / user / Documents / development / spabrutaltree / node_modules / vue-loader / lib / loaders / templateLoader.js: 63) at Object ../ node_modules / vue-loader / lib / loaders / templateLoader.js? ! ./ node_modules / vue-loader / lib / index.js?! ./ resources / js / views / Main.vue? vue & type = template & id = 2ad93e50 & (app.js: 629) at webpack_require (app.js: 20) at Module .. / resources / js / views / Main.vue? Vue & type = template & id = 2ad93e50 & (app.js: 15428) at webpack_require (app.js: 20) at Module ../ resources / js / views / Main.vue ( app.js: 15393) at webpack_require (app.js: 20) at Module ../ resources / js / app.js (app.js: 15291) at webpack_require (app.js: 20) at Object.0 (app. js: 15453) at webpack_require (app.js: 20)

What is the problem?

  • one
    </ p> tag is not closed, as an option - Valera Kvip
  • I closed the tag, tried again. The result is the same - Baselik Green

2 answers 2

I also had it. And it is interesting that when compiling on local computers (Ubuntu) everything is in order, but on one server environment (CentOS Linux 7) with the same compilation conditions - an error. (There and there - the last NodeJS.)

It appeared in node_modules / vue-template-compiler / build.js and in node_modules / vue-template-compiler / browser.js indeed, in the function $ repeat. With the second parameter less than 0, it gives this error. In the source package of the latest version 2.6.6 - not fixed, 2.5.17 - also. In order to not arise, it is necessary to write the function like this (for example)

 function repeat$1 (str, n) { var result = ''; while (true) { // eslint-disable-line // if (n & 1) { result += str; } // n >>>= 1; // if (n <= 0) { break } if(str.length >280 || (n && (result += str), (n >>>= 1) <= 0)) break; str += str; } return result } 

Or patch a compressed function like this:

 function Ra(e,t){for(var n="";;){if(e.length >280 || (t && (n += e), (t >>>= 1) <= 0))break;e+=e}return n} 

In the process of work, the execution of the code repeat $ 1 ('^', - 1) led to an error, in the patched version - no.

    When you create an object with a view, you cannot see that you are telling it that within its template there is an App component. Try to register hard render:

     const app = new Vue({ el: '#app', components: { App }, router, render: h => h(App) });