Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
argh! Exports! Unexpected token 'export'.
I’m still fairly new to this model of development.
I started my project a while ago and use AWS API Gateway, Cognito, CognitoSync and PinPoint. At the time, I downloaded the libraries and added them manually to my JS folder, and it works.
I now want to make them more manageable, so I have removed them and am trying to add them by using the JS/CSS Components feature of Monaca.
My main problem currently is the following:
Uncaught SyntaxError: Unexpected token ‘export’ www/components/loader.js:1577
Is there anyway to update my version of JS so that it supports modules?
Did you edit loader.js manually? If so, try deleting it and recreating it just using the JS/CSS Components page.
If not, can you check which component is causing the problem?
I have not edited the file directly, so I have not deleted and recreated, I can if that will help, but removing the components also helps…
It happens if I add aws-sdk or aws-sdk-js. (I’m using the -js one currently, as i am assuming thats the correct version, but there is no detail or readme of anything with any of the js components to describe them so its a bit difficult).
Also, as a side note, a better way of including of excluding the files from the install page would be a welcome addition. There are a lot of files in the AWS-sdk to include or exclude, clicking every single one takes ages. a Select-All/None and even a filter by name, ie, cognito would be a massive improvement.
Regardless, I have just installed aws-sdk-js and selected a single file; components/aws-sdk-js/aws-sdk.min.js
and i get the following error: Uncaught SyntaxError: Cannot use import statement outside a module www/components/loader.js:47743
lordvillage last edited by lordvillage
I wondered if maybe the versions had something to do with it as well, I loaded 2.649 manually, and i was importing the latest (as i want to try and keep it up to date).
it worked at first when i loaded 2.649, but then when I added cognito files (using configure) i get:
Uncaught ReferenceError: require is not defined www/components/loader.js:1567
line 1567 and a few above/below are included below:
/*** <Start:aws-sdk-js LoadJs:“components/aws-sdk-js/clients/apigateway.js”> ***/
var AWS = require(’…/lib/core’);
var Service = AWS.Service;
var apiLoader = AWS.apiLoader;
I think the problem is that require is a function known by Node but it is not understood by browsers.
If your library is intended for use in the browser, you’ll need to use something to get require to work (and any other functions that are not supported in the browser).
The same question was asked here and there are some suggestions for what you might try:
Ah, ok that makes sense. Shame though, means that updating the aws-sdk by using the JS/CSS Components is pretty useless.
I think as long as you include something that defines require (e.g. requirejs) before the loader.js script it should work (assuming require is the only thing missing)
steve last edited by
Hivelance is a NFT Token development company that specializes in creating custom NFT solutions for clients across a wide range of industries, Our NFT Token development services include designing and developing smart contracts on Ethereum and other blockchain platforms, creating unique and custom NFT Tokens and integrating various blockchain technologies. Hivelance has a team of experienced blockchain developers who specialize in creating NFT Projects like NFT token development. We working closely with clients to understand their requirements and provide the best solutions. We prioritize communication and transparency throughout the development process.