title: Node.js - Uncaught SyntaxError: Unexpected token 'export'
body: <p>Im trying to learn Node.js server side and trying to come to grips on how to use it.</p>
  
  <p>I keep getting an error "Uncaught SyntaxError: Unexpected token 'export'"</p>
  
  <p>I have installed Node.js on visual studio npm, installed common.js and express.js</p>
  
  <p>my package.json</p>
  
  <pre><code>{
  "name": "test3",
  "version": "1.0.0",
  "private": true,
  "description": "test program",
  "main": "index.js",
  "dependencies": {
  "common-js": "^0.3.8",
  "express": "^4.17.1"
  },
  "devDependencies": {
  "@babel/core": "^7.9.0",
  "@babel/preset-env": "^7.9.0",
  "@babel/register": "^7.9.0"
  },
  "scripts": {
  "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "type": "module",
  "author": "xxx",
  "license": "ISC"
   }
  </code></pre>
  
  <p>Not sure why im getting this error, if tried everything.</p>
  
  <p>All i want to do is make a request to the action method in mvc controller.
  This is the app.js</p>
  
  <pre><code>'use strict';
  
  define(function (require) {
  var express = require('express');
  var app = express();
  var server = app.listen(57743);
  app.use(express.static('public'));
  app.get('/AddSubscribe', sayHello);
  });
  </code></pre>
  
  <p>Full error:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token 'export'
  require.js:5 Uncaught Error: Module name "@babel/register" has not been loaded yet for context: _. 
  Use require([])
  https://requirejs.org/docs/errors.html#notloaded
  at makeError (require.js:5)
  at Object.s [as require] (require.js:5)
  at requirejs (require.js:5)
  at start.js:1
  require.js:5 Uncaught Error: Mismatched anonymous define() module: function (exports, $, Popper) { 
   'use strict';
  
   $ = $ &amp;&amp; $.hasOwnProperty('default') ? $['default'] : $;
   Popper = Popper &amp;&amp; Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  
  function _defineProperties(target, props) {
  for (var i = 0; i &lt; props.length; i++) {
    var descriptor = props[i];
    descriptor.enumerable = descriptor.enumerable || false;
    descriptor.configurable = true;
    if ("value" in descriptor) descriptor.writable = true;
    Object.defineProperty(target, descriptor.key, descriptor);
  }
  }
  
   function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
   }
  
   function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  
  return obj;
  }
  
  function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);
  
  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    if (enumerableOnly) symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    });
    keys.push.apply(keys, symbols);
  }
  
  return keys;
  } 
  
  function _objectSpread2(target) {
  for (var i = 1; i &lt; arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};
  
    if (i % 2) {
      ownKeys(Object(source), true).forEach(function (key) {
        _defineProperty(target, key, source[key]);
      });
    } else if (Object.getOwnPropertyDescriptors) {
      Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
      ownKeys(Object(source)).forEach(function (key) {
        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
      });
    }
   }
  
  return target;
  }
  
  function _inheritsLoose(subClass, superClass) {
  subClass.prototype = Object.create(superClass.prototype);
  subClass.prototype.constructor = subClass;
  subClass.__proto__ = superClass;
  }
  
  
   var TRANSITION_END = 'transitionend';
   var MAX_UID = 1000000;
   var MILLISECONDS_MULTIPLIER = 1000; 
  
   function toType(obj) {
  return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  }
  
   function getSpecialTransitionEndEvent() {
  return {
    bindType: TRANSITION_END,
    delegateType: TRANSITION_END,
    handle: function handle(event) {
      if ($(event.target).is(this)) {
        return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
      }
  
      return undefined; // eslint-disable-line no-undefined
    }
  };
  }
  
   function transitionEndEmulator(duration) {
  var _this = this;
  
  var called = false;
  $(this).one(Util.TRANSITION_END, function () {
    called = true;
  });
  setTimeout(function () {
    if (!called) {
      Util.triggerTransitionEnd(_this);
    }
  }, duration);
  return this;
  }
  
  function setTransitionEndSupport() {
  $.fn.emulateTransitionEnd = transitionEndEmulator;
  $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  }
  
  
  
  var Util = {
  TRANSITION_END: 'bsTransitionEnd',
  getUID: function getUID(prefix) {
    do {
      // eslint-disable-next-line no-bitwise
      prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
    } while (document.getElementById(prefix));
  
    return prefix;
  },
  getSelectorFromElement: function getSelectorFromElement(element) {
    var selector = element.getAttribute('data-target');
  
    if (!selector || selector === '#') {
      var hrefAttr = element.getAttribute('href');
      selector = hrefAttr &amp;&amp; hrefAttr !== '#' ? hrefAttr.trim() : '';
    }
  
    try {
      return document.querySelector(selector) ? selector : null;
    } catch (err) {
      return null;
    }
  },
  getTransitionDurationFromElement: function getTransrequire.js:5)
  at T (require.js:5)
  at require.js:5
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public JsonResult AddSubscribe(string name, string email, string message, int? sub)
      {
  
  
  
          return Json(new { success = "success"}, JsonRequestBehavior.AllowGet);
      }
  </code></pre>