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.

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, i missed that. but, when I try, I get this error: ParseError: Unexpected token. @ "<template>"
0

*use import

import Vue from 'vue'
import VueRouter from 'vue-router'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.