Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite V3.0.0 vite.config.ts 引入插件报错(***** is not a function) #9414

Closed
7 tasks done
RayforReal opened this issue Jul 28, 2022 · 5 comments
Closed
7 tasks done

Comments

@RayforReal
Copy link

Describe the bug

  • 启动项目 npm run dev
import vue from '@vitejs/plugin-vue';
import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'

export default defineConfig((): UserConfig => {
    consolo.log(vueSetupExtend);  //{ default: [Function (anonymous)] }
    return {
        base: '/',
        plugins: [
            vue(),
            vueSetupExtend() ; // TypeError: vueSetupExtend is not a  @function
        ],
    }
})


### Reproduction

\

### System Info

```shell
failed to load config from C:\Users\49324\Desktop\work\sea_angle\vite.config.ts
error when starting dev server:
TypeError: vueSetupExtend is not a function
    at file:///C:/Users/49324/Desktop/work/sea_angle/vite.config.ts.timestamp-1659010417526.mjs:14:7
    at loadConfigFromFile (file:///C:/Users/49324/Desktop/work/sea_angle/node_modules/vite/dist/node/chunks/dep-c6273c7a.js:62765:15)
    at async resolveConfig (file:///C:/Users/49324/Desktop/work/sea_angle/node_modules/vite/dist/node/chunks/dep-c6273c7a.js:62380:28)
    at async createServer (file:///C:/Users/49324/Desktop/work/sea_angle/node_modules/vite/dist/node/chunks/dep-c6273c7a.js:59000:20)
    at async CAC.<anonymous> (file:///C:/Users/49324/Desktop/work/sea_angle/node_modules/vite/dist/node/cli.js:699:24)

Used Package Manager

npm

Logs

No response

Validations

@caoxiemeihao
Copy link
Contributor

caoxiemeihao commented Jul 28, 2022

Found the same problem 👉 TypeError: electron is not a function

@RayforReal
Copy link
Author

如果把vite版本降低到V2.9.0就不会报错

@github-actions
Copy link

Hello @Balott. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@bluwy
Copy link
Member

bluwy commented Jul 29, 2022

vite-plugin-vue-setup-extend-plus is exporting the plugin under exports.default, which correctly translates to { default: [Function (anonymous)] } in nodejs. Hence, you need to access the .default instead. The correct fix is to export under exports directly (not exports.default) in the plugin.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2022
@RayforReal
Copy link
Author

删掉package.json 中的 "type": "module"配置

@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants