ModyQyW / vite-plugin-stylelint

🚨 Stylelint plugin for Vite.
MIT License
23 stars 1 forks source link

Error: Dynamic require of "tty" is not supported #31

Closed ianzone closed 1 year ago

ianzone commented 1 year ago

描述问题

failed to load config from /home/ian/acte/roomzz-v1/admin_ts/vite.config.ts error when starting dev server: Error: Dynamic require of "tty" is not supported at file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite-plugin-stylelint@4.0.1_hdr6qhp2cp4t47liatlblyjedi/node_modules/vite-plugin-stylelint/dist/index.js:1:376 at file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite-plugin-stylelint@4.0.1_hdr6qhp2cp4t47liatlblyjedi/node_modules/vite-plugin-stylelint/dist/index.js:1:853 at file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite-plugin-stylelint@4.0.1_hdr6qhp2cp4t47liatlblyjedi/node_modules/vite-plugin-stylelint/dist/index.js:1:491 at file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite-plugin-stylelint@4.0.1_hdr6qhp2cp4t47liatlblyjedi/node_modules/vite-plugin-stylelint/dist/index.js:1:2468 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24) at async loadConfigFromBundledFile (file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite@4.0.1_p56klvi3zg3u723wp3set4h7pe/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:63052:21) at async loadConfigFromFile (file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite@4.0.1_p56klvi3zg3u723wp3set4h7pe/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:62937:28) at async resolveConfig (file:///home/ian/acte/roomzz-v1/admin_ts/node_modules/.pnpm/vite@4.0.1_p56klvi3zg3u723wp3set4h7pe/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:62558:28)  ELIFECYCLE  Command failed with exit code 1.

复现

my vite.config.ts setting is

import react from "@vitejs/plugin-react-swc"; import { resolve } from 'path'; import eslintPlugin from 'vite-plugin-eslint'; import stylelintPlugin from 'vite-plugin-stylelint'; import { defineConfig } from 'vitest/config';

export default defineConfig({ test: { globals: true, environment: 'happy-dom', }, plugins: [ react(), stylelintPlugin(), eslintPlugin() ], resolve: { alias: { src: resolve(__dirname, 'src'), }, }, });

系统信息

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    Memory: 5.60 GB / 7.69 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 18.12.0 - ~/.local/share/pnpm/node
    npm: 8.19.2 - ~/.local/share/pnpm/npm

使用的包管理器

pnpm

核对

PodaruDragos commented 1 year ago

Stumbled upon this and wanted to add that this is happening in a fresh vite v4 project.

felixranesberger commented 1 year ago

I'm facing the same issue with Vite@3 and Vite@4.

Workarround: When using vite-plugin-stylelint with Vite@4 and vite-plugin-stylelint@3.3.3 the installation process throws a warning but still functions correclty.

ModyQyW commented 1 year ago

Can you please try v4.0.2? @ianzone @PodaruDragos @felixranesberger

Dynamic require is a doom to me, really...

felixranesberger commented 1 year ago

Hi, thanks for your fast response. What version do I need to install?

The latest version of Vite is currently 4.0.1

Do you mean 4.0.0-beta.2?

ModyQyW commented 1 year ago

vite-plugin-stylelint v4.0.2 actually

felixranesberger commented 1 year ago

Works like a charm, thanks for the help!

ModyQyW commented 1 year ago

@ianzone @PodaruDragos Can you please try the new version of vite-plugin-stylelint and tell me if it is fine? Thanks!

ianzone commented 1 year ago

@ianzone @PodaruDragos Can you please try the new version of vite-plugin-stylelint and tell me if it is fine? Thanks!

HI, it works perfectly, THX

PodaruDragos commented 1 year ago

@ModyQyW works fine with 4.0.4, thanks for the quick fix, really appreciated it.