[dcloudio/uni-app]node 18 无法正常编译

2024-02-22 954 views
2

问题描述

项目是由 vue create -p dcloudio/uni-preset-vue my-project 命令创建的,使用 node 18.12 运行会卡在编译这一步,切换到 node 16x 是正常的

实际结果

image

会一直卡在正在编译当前项目这一步。

系统信息: npm run info的运行结果:

> my-project@0.1.0 info
> node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js

uni-app v3.6.9
uni-app cli v2.0.1-alpha-36920221111002

Environment Info:

  System:
    OS: macOS 13.0.1
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 18.12.0 - ~/.nvm/versions/node/v18.12.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.0/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Firefox: Not Found
    Safari: 16.1
  npmPackages:
    @dcloudio/types: ^3.0.4 => 3.0.19
    @dcloudio/uni-app: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-app-plus: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-app-plus-nvue:  0.0.1
    @dcloudio/uni-app-plus-nvue-v8:  0.0.1
    @dcloudio/uni-automator: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-cli-i18n: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-cli-shared: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-h5: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-helper-json: * => 1.0.13
    @dcloudio/uni-i18n: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-migration: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-360: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-alipay: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-baidu: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-jd: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-kuaishou: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-lark: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-qq: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-toutiao: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-vue: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-weixin: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-mp-xhs: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-quickapp-native: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-quickapp-webview: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-stacktracey: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-stat: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/uni-template-compiler: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/vue-cli-plugin-uni: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/webpack-uni-mp-loader: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @dcloudio/webpack-uni-nvue-loader:  0.0.1
    @dcloudio/webpack-uni-pages-loader: ^2.0.1-alpha-36920221111002 => 2.0.1-alpha-36920221111002
    @hap-toolkit/dsl-vue:  0.6.13
    @vue/babel-helper-vue-jsx-merge-props:  1.4.0
    @vue/babel-helper-vue-transform-on:  1.0.2
    @vue/babel-plugin-jsx:  1.1.1
    @vue/babel-plugin-transform-vue-jsx:  1.4.0
    @vue/babel-preset-app:  4.5.19
    @vue/babel-preset-jsx:  1.4.0
    @vue/babel-sugar-composition-api-inject-h:  1.4.0
    @vue/babel-sugar-composition-api-render-instance:  1.4.0
    @vue/babel-sugar-functional-vue:  1.4.0
    @vue/babel-sugar-inject-h:  1.4.0
    @vue/babel-sugar-v-model:  1.4.0
    @vue/babel-sugar-v-on:  1.4.0
    @vue/cli-overlay:  4.5.19
    @vue/cli-plugin-babel: ~4.5.19 => 4.5.19
    @vue/cli-plugin-router:  4.5.19
    @vue/cli-plugin-vuex:  4.5.19
    @vue/cli-service: ~4.5.19 => 4.5.19
    @vue/cli-shared-utils:  4.5.19
    @vue/compiler-sfc:  2.7.14
    @vue/component-compiler-utils:  3.3.0 (3.3.0)
    @vue/composition-api:  1.7.0
    @vue/devtools-api:  6.0.0-beta.15
    @vue/preload-webpack-plugin:  1.1.2
    @vue/shared: ^3.0.0 => 3.2.45
    @vue/web-component-wrapper:  1.3.0
    mpvue-page-factory:  1.0.1
    mpvue-template-compiler:  1.0.13
    uni-h5-vue:  2.6.10
    uni-mp-vue:  2.6.10
    vue: ^2.6.11 => 2.7.14
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.10.0 (16.8.3, 15.10.0)
    vue-router:  3.0.1
    vue-style-loader:  4.1.3 (4.1.3)
    vue-template-compiler: ^2.6.11 => 2.7.14 (2.7.14)
    vue-template-es2015-compiler:  1.9.1
    vue3:  1.0.0
    vuex: ^3.2.0 => 3.6.2 (3.6.2)
  npmGlobalPackages:
    @vue/cli: 4.5.19

回答

8

使用 @vue/cli@5 创建,或者 node 降级到 18 以下。

2

已更新相关文档

1

https://github.com/dcloudio/uni-app/issues/3476

@zhetengbiji node 17.9.1 任然有vuex的错误 Package subpath './dist/vuex.esm-bundler.js' is not defined by "exports" in ../node_modules/vuex/package.json;请问这个还解决吗?

"@dcloudio/uni-app": "3.0.0-alpha-3060820221027002", "vuex": "4.0.2" "vue": "3.2.41", "vite": "3.1.8",

5

仅 node17 存在此错误吗?

0

node/16.15.1 正常 node/17.9.1 Package subpath './dist/vuex.esm-bundler.js' is not defined by "exports" in /node_modules/vuex/package.json node/18.12.1 Package subpath './dist/vuex.esm-bundler.js' is not defined by "exports" in /node_modules/vuex/package.json

2

感谢提醒,已更新文档