Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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>

like image 773
mariocatch Avatar asked Mar 31 '16 19:03

mariocatch


1 Answers

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.

like image 196
mariocatch Avatar answered Oct 18 '22 02:10

mariocatch