mariocatch
mariocatch

Reputation: 8703

"Uncaught SyntaxError: Unexpected token import" when using momentjs with ASP5/MVC6

When I try to use momentjs, installed through bower, my web app runs into the following error when the javascript file for moment is attempted to be loaded:

Uncaught SyntaxError: Unexpected token import

On this line:

import { hooks as moment, setHookCallback } from './lib/utils/hooks';

I am using ASP5, MVC6, Visual Studio 2015 Community. Couldn't find any answers to this here or on documentation from momentjs.

My script tag looks like:

<script type="text/javascript" src="~/lib/moment/src/moment.js"></script>

Upvotes: 12

Views: 9809

Answers (1)

mariocatch
mariocatch

Reputation: 8703

Looks like they include a built version of it already. I was using the src version, which isn't compiled. Just point to the min version and it'll be there, which is compiled.

Upvotes: 27

Related Questions