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

138
Views
dependency cycle detected import/no-cycle

I am trying to set up API endpoints in ES6. In my main server file, I tried to import the router module but I get the error "dependency cycle detected import/no-cycle". Please find my code below for clearance and assistance.

import express from 'express';

import bodyParser from 'body-parser';

import router from './routes/routes';

const app = express();
const PORT = process.env.PORT || 8080;

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// app.use(routes);

app.use('/api/v1', router);

const run = () => console.log('way to go server!');

app.listen(PORT, run);
export default app;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This could be a direct reference (A -> B -> A) issue, which even you might be doing.

// file a.ts
import { b } from 'b';
...
export a;

// file b.ts
import { a } from 'a';
...
export b;

Read HERE more about "Eliminate Circular Dependencies from Your JavaScript Project":

Once I had the issue in vue.js project and the code that had issue was something like this:

<script>
  import router from '@/router';
  import { requestSignOut } from '../../api/api';

  export default {
    name: 'sign-out',
    mounted() {
      requestSignOut().then((data) => {
        if (data.status === 'ok') {
          router.push({ name: 'sign-in' });
        }
      });
    },
  };
</script>

Then I fixed it this way:

<script>
import { requestSignOut } from '@/api/api';

export default {
  name: 'sign-out',
  mounted() {
    requestSignOut().then((data) => {
      if (data.status === 'ok') {
        this.$router.push({ name: 'sign-in' });
      }
    });
  },
};
</script>
over 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!