0

I am trying to get started with this: https://github.com/vuejs/vue-router

I have cloned the package, and followed the instructions to build:

npm install
npm run build

But I am receiving a "Require is not defined" error on:

var Vue = require('vue')
var VueRouter = require('../src')

in /example/example.js

I have installed node and browserify... Not sure what to do.

noland
  • 125
  • 2
  • 10

2 Answers2

1

Have you done the following after you installed Browserify?

1) bundle all your .js files into one file (e.g. 'bundle.js') using command:

browserify example/example.js -o bundle.js

2) put 'bundle.js' script into your .html file:

<script src="bundle.js"></script>

Important: Do not put 'example.js' script into .html file as 'bundle.js' already includes everything from your 'example.js' file.

Mikhail Romanov
  • 1,542
  • 1
  • 13
  • 20
  • thanks, i missed that. but, when I try, I get this error: ParseError: Unexpected token. @ " – noland Jul 27 '15 at 18:56
0

*use import

import Vue from 'vue'
import VueRouter from 'vue-router'
SAKIB
  • 475
  • 5
  • 7