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

637
Views
Vue 3 "Uncaught ReferenceError: require is not defined"

I am working on my first Vue 3 project after using Vue 2 for a long time.

Normally in my components on Vue 2 projects I can import a library, for example moment, like so:

<script>
const moment = require("moment")
export default {
  ...
</script>

In vue 3, I'm trying to do the same:

<script setup>
const moment = require("moment")
</script>

However I get the error

Uncaught ReferenceError: require is not defined

How can I get around this and import modules into a vue3 component?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can not use require in Vite, did you try with import:

<script setup>
  import moment from 'moment'
about 4 years ago · Juan Pablo Isaza 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!