Attempted import error: '@module' does not contain a default export (imported as 'module')
Asked Answered
A

0

7

I'm using craco to create a react app. Here are my ts configs:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "downlevelIteration": true
  },
  "include": [
    "src"
  ]
}

I'm also using a git submodule to import utils from it.

When I run craco start everything works fine. But when I run craco build I get this error:

Attempted import error: '@pinata/sdk' does not contain a default export (imported as 'pinataClient')

This is how pinataClient is imported:

import pinataClient "@pinata/sdk";

When I edit this line to

const pinataClient = require("@pinata/sdk");

Here is the tsconfig file of the submodule:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "outDir": "dist",
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true
  },
  "include": ["./test", "./tasks", "./utils"],
  "files": ["./hardhat.config.ts"]
}

I think it is a webpack error, but I can't seem to figure it out.

Astute answered 6/4, 2022 at 10:57 Comment(2)
did you figure this out? I'm having the same issue and I'm also using cracoThoroughgoing
no sorry :( Maybe upvote the post to make it more visibleAstute

© 2022 - 2024 — McMap. All rights reserved.