包不提供默认导出

问题描述 投票:0回答:0

我在我的测试项目中使用了一个 npm 包,它在使用

caught SyntaxError: The requested module '/@fs/Users/package/module/index.js' does not provide an export named 'default'
构建项目时抱怨
vite
,但是使用 webpack 一切正常。

我的 tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

和vite配置

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})
javascript typescript webpack bundler vite
© www.soinside.com 2019 - 2024. All rights reserved.