unocss / unocss

The instant on-demand atomic CSS engine.

Home Page:https://unocss.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error when starting dev server: TypeError: (0 , _presetWind.presetWind) is not a function

pdsuwwz opened this issue · comments

UnoCSS version

0.60.4

Describe the bug

Running the project results in an error:

➜  unocss-vite-test npm run dev

> unocss-vite-test@0.0.0 dev
> vite

error when starting dev server:
TypeError: (0 , _presetWind.presetWind) is not a function
    at /Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/preset-uno/dist/index.mjs:69:43
    at /Users/wisdom/Documents/workspace/others/unocss-vite-test/uno.config.ts:10:25
    at evalModule (/Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/jiti/dist/jiti.js:1:247359)
    at jiti (/Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/jiti/dist/jiti.js:1:245172)
    at loadConfigFile (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/unconfig/dist/index.mjs:177:13)
    at async Object.load (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/unconfig/dist/index.mjs:98:24)
    at async loadConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/config/dist/index.mjs:43:18)
    at async reloadConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:93:20)
    at async Object.updateRoot (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:125:12)
    at async configResolved (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:1031:7)
    at async Promise.all (index 2)
    at async resolveConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:69639:5)
    at async _createServer (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:65857:20)
    at async CAC.<anonymous> (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/cli.js:762:24)

image

image

uno.config.ts:

import {
  defineConfig,
  presetAttributify,
  presetUno,
  transformerDirectives
} from 'unocss'

export default defineConfig({
  presets: [
    presetUno(),
    presetAttributify(),
  ],
  transformers: [
    transformerDirectives()
  ],
})

vite.config.ts:

import { fileURLToPath, URL } from 'node:url'

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

import UnoCSS from 'unocss/vite'


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    UnoCSS(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Reproduction

https://github.com/pdsuwwz/unocss-vite-test

https://stackblitz.com/edit/unocss-unocss-whabz3?file=uno.config.ts,vite.config.ts

System Info

No response

Validations

同问
image

我也是,刚刚出现了,本地可以编译,阿里云云效流水线报错

UnoCSS version

0.60.4

Describe the bug

Running the project results in an error:

➜  unocss-vite-test npm run dev

> unocss-vite-test@0.0.0 dev
> vite

error when starting dev server:
TypeError: (0 , _presetWind.presetWind) is not a function
    at /Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/preset-uno/dist/index.mjs:69:43
    at /Users/wisdom/Documents/workspace/others/unocss-vite-test/uno.config.ts:10:25
    at evalModule (/Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/jiti/dist/jiti.js:1:247359)
    at jiti (/Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/jiti/dist/jiti.js:1:245172)
    at loadConfigFile (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/unconfig/dist/index.mjs:177:13)
    at async Object.load (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/unconfig/dist/index.mjs:98:24)
    at async loadConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/config/dist/index.mjs:43:18)
    at async reloadConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:93:20)
    at async Object.updateRoot (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:125:12)
    at async configResolved (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/@unocss/vite/dist/index.mjs:1031:7)
    at async Promise.all (index 2)
    at async resolveConfig (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:69639:5)
    at async _createServer (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:65857:20)
    at async CAC.<anonymous> (file:///Users/wisdom/Documents/workspace/others/unocss-vite-test/node_modules/vite/dist/node/cli.js:762:24)

image

image

uno.config.ts:

import {
  defineConfig,
  presetAttributify,
  presetUno,
  transformerDirectives
} from 'unocss'

export default defineConfig({
  presets: [
    presetUno(),
    presetAttributify(),
  ],
  transformers: [
    transformerDirectives()
  ],
})

vite.config.ts:

import { fileURLToPath, URL } from 'node:url'

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

import UnoCSS from 'unocss/vite'


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    UnoCSS(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Reproduction

https://github.com/pdsuwwz/unocss-vite-test

https://stackblitz.com/edit/unocss-unocss-whabz3?file=uno.config.ts,vite.config.ts

System Info

No response

Validations

commented

I also encountered this issue today. The reason is that the upstream jiti package was upgraded from 1.21.0 to 1.21.1, which caused problems with the downstream unocss package. The solution is to fix the version of the jiti package. If you are using pnpm, you can write this in the package.json:

{
  "pnpm": {
    "overrides": {
      "jiti": "1.21.0"
    }
  }
}

Had the same problem with a clean install of UnoCSS and I saw the example from UnoCSS docs in stackblitz had the exact same error.

Had the same problem with a clean install of UnoCSS and I saw the example from UnoCSS docs in stackblitz had the exact same error.

Yes, and older versions are also impacted: 0.60.3, 0.60.2, etc.
@hex-ci provided an explanation and a solution that works (thanks @hex-ci 🙏).

If you are using npm, add it to the package.json root tag:
"overrides": {
"jiti": "1.21.0"
}

jiti@1.21.2 was released as a hotfix for this issue. You can remove the resolution and upgrade your lock file to receive the fix 🤞🏼