最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Vite errors out from node_modules - Stack Overflow

matteradmin6PV0评论

I am trying build using vite. How can I make it not error out on packages out of my control?

import {defineConfig, transformWithEsbuild} from 'vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { createHtmlPlugin } from 'vite-plugin-html';
import baseViteConfig from "./base.config";

const serverUrl = ":1070/";

export default defineConfig({
    ...baseViteConfig,
    mode: 'development',
    root: path.resolve(__dirname, '../src'),
    build: {
        outDir: path.resolve(__dirname, '../dist'),
        rollupOptions: {
            input: {
                main: path.resolve(__dirname, '../src/index.html')
            },
            output: {
                entryFileNames: 'client.min.js'
            }
        }
    },
    plugins: [
        react(),
        createHtmlPlugin({
            inject: {
                data: {
                    serverUrl: serverUrl
                }
            },
            minify: false,
            template: '../src/maintenance.html',
            filename: '../dist/maintenance.html'
        })
    ],
    server: {
        open: true,
        hot: true,
        watch: {
            usePolling: true
        }
    },
    esbuild: {
        loader: "tsx", // OR "jsx"
        include: [
            // Add this for business-as-usual behaviour for .jsx and .tsx files
            "src/**/*.jsx",
            "src/**/*.tsx",

            // Add these lines to allow all .js files to contain JSX
            "src/**/*.js",

            // Add these lines to allow all .ts files to contain JSX
            "src/**/*.ts",
        ],
    },
});

errors

[TypeScript] Found 0 errors. Watching for file changes.
✘ [ERROR] Unterminated string literal

    node_modules/react-multiselect-checkboxes/lib/DropdownButton.jsx:33:2:
      33 │ ',
         ╵   ^

✘ [ERROR] Expected ";" but found "CheckboxOption"

    node_modules/react-multiselect-checkboxes/lib/CheckboxOption.jsx:41:1:
      41 │ }CheckboxOption.defaultProps = {
         │  ~~~~~~~~~~~~~~
         ╵  ;

✘ [ERROR] Unterminated regular expression

    node_modules/react-multiselect-checkboxes/lib/Dropdown.jsx:10:74:
      10 │       {isOpen ? <Menu rightAligned={rightAligned>{children}</Menu> : null}
         ╵                                                                           ^

✘ [ERROR] The symbol "getOptionValue" has already been declared

    node_modules/react-multiselect-checkboxes/lib/CheckboxGroup.jsx:20:8:
      20 │   const getOptionValue = props.selectProps.getOptionValue;
         ╵         ~~~~~~~~~~~~~~

  The symbol "getOptionValue" was originally declared here:

    node_modules/react-multiselect-checkboxes/lib/CheckboxGroup.jsx:7:8:
      7 │   const {
        ╵         ^

I understand these are actual errors, but I can't remove them. Webpack built it with no issue

Post a comment

comment list (0)

  1. No comments so far