amir_70
amir_70

Reputation: 930

export 'x' (imported as 'y') was not found in 'z'

I know, I know there are lots of questions about this topic out there and I read them as much as I could but believe me non of them gave me my answer.

my code is simple: I have a file named data.js like this:

export const data = [
  {
    title: "HOME",
    icon: <MdHome />,
  },
  //and some more objects like this
];

export const portfolioData = [
  {
    title: "NetFlix movie",
    path: "",
  },
  //and some more objects like this
];

export const skillsData = [
  {
    title: "photoshop",
    percentage: "90",
  },
//and some more objects like this
];

export const test = [
  { name: "x", lastname: "y" },
  //and some more object like this
];

so I have four named export here . In another folder I have another file and i want to use these data that exported.

here is the code for imports :

import { data } from "../utils/data";
import { portfolioData } from "../utils/data";
import { test } from "../utils/data";
import { skillsData } from "../utils/data";

the problem is that now, when i want to use these imports. just two of them (data and portfolioData) works as normal but the last two imports gives me error :

    ERROR in ./src/pages/Homepage.js 59:37-41
    export 'test' (imported as 'test') was not found in '../utils/data' (possible exports: data, portfolioData)
ERROR in ./src/pages/Homepage.js 59:37-41
export 'skillsData' (imported as 'skillsData') was not found in '../utils/data' (possible exports: data, portfolioData)

how could it be possible that in a same file with same exports method and with the same import method as you can clearly see, two of them work and two of them dont work? and the weird thing is that if I change portfolioData name to for example "someName" and then import it as import {someName} from "../utils/data", now it stops working anymore.

Upvotes: 0

Views: 1663

Answers (1)

codejockie
codejockie

Reputation: 10864

Could you try importing all those with a single line and see if it works? Something like this:

import { data, portfolioData, skillsData, test } from '../utils/data';

While at it, ensure the data file containing the exports is saved as this could also be an issue when new exports are added and the file is not saved.

Upvotes: 2

Related Questions