Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
load js file in requirejs-config.js in magento2

how to load this js file in requirejs?

<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>

my requirejs-config.js file=?

var config = {
  paths: {
    modelviewer: "Ajith_CustomModule/js/modelviewer.min",
       .....
       .....
       .....

and load this file in my phtml file


<script type="module">


require(['jquery'.......,'modelviewer'],function($,..,model){
});

</script>
    .....
    ..... 
   .....

shows this error => Uncaught SyntaxError: Unexpected token 'export'

anybody please help me to fix this problem.

Thanks in advance

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

RequireJS does not support native JS modules. You have to load it as regular JS module, working example:

<script type="module">
  import { ModelViewerElement } from 'https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js';
  
  console.log(ModelViewerElement);
</script>

(tested on Chrome 96)

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!