dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.17k stars 3.64k forks source link

初始化typescript版本失败 #1126

Closed passioncsu closed 4 years ago

passioncsu commented 4 years ago

问题描述 [问题描述:] 初始化typescript版本失败 复现步骤 [复现问题的步骤]

$ screenfetch 
                   -`                 
                  .o+`                 passion@pchome
                 `ooo/                 OS: Arch Linux 
                `+oooo:                Kernel: x86_64 Linux 5.4.2-arch1-1
               `+oooooo:               Uptime: 9h 58m
               -+oooooo+:              Packages: 889
             `/:-:++oooo+:             Shell: zsh 5.7.1
            `/++++/+++++++:            Resolution: 1920x1080
           `/++++++++++++++:           DE: Xfce4
          `/+++ooooooooooooo/`         WM: Xfwm4
         ./ooosssso++osssssso+`        WM Theme: Default
        .oossssso-````/ossssss+`       GTK Theme: Adwaita [GTK2]
       -osssssso.      :ssssssso.      Icon Theme: Adwaita
      :osssssss/        osssso+++.     Font: Sans 10
     /ossssssss/        +ssssooo/-     Disk: 43G / 117G (39%)
   `/ossssso+/:-        -:/+osssso+-   CPU: Intel Core i5-6400 @ 4x 3.3GHz [33.0°C]
  `+sso+:-`                 `.-/+oso:  GPU: GeForce GTX 750 Ti
 `++:.                           `-/+/ RAM: 5953MiB / 15952MiB
 .`                                 `/

# passion @ pchome in ~/Downloads [9:12:30] 
$ node -v
v13.3.0

# passion @ pchome in ~/Downloads [9:12:34] 
$ npm -v
6.13.4

# passion @ pchome in ~/Downloads [9:12:37] 
$ yarn -v
1.21.1

# passion @ pchome in ~/Downloads [9:12:54] C:1
$ vue -V
@vue/cli 4.1.1

# passion @ pchome in ~/Downloads [9:13:42] 
$ vue create -p dcloudio/uni-preset-vue test      
✔  Fetching remote preset dcloudio/uni-preset-vue...

Vue CLI v4.1.1
✨  Creating project in /home/passion/Downloads/test.
🗃  Initializing git repository...
⚙  Installing CLI plugins. This might take a while...

yarn install v1.21.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.11: The platform "linux" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...

success Saved lockfile.
Done in 28.16s.
🚀  Invoking generators...

Preset options:
? 请选择 uni-app 模板 默认模板(TypeScript)
📦  Installing additional dependencies...

yarn install v1.21.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.11: The platform "linux" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 8.91s.
⚓  Running completion hooks...

📄  Generating README.md...

🎉  Successfully created project test.
👉  Get started with the following commands:

 $ cd test
 $ yarn serve

# passion @ pchome in ~/Downloads [9:14:45] 
$ cd test 

# passion @ pchome in ~/Downloads/test on git:master o [9:14:50] 
$ yarn serve
yarn run v1.21.1
$ npm run dev:h5
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1576372493395-0.06153810028329865/node but npm is using /usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> test@0.1.0 dev:h5 /home/passion/Downloads/test
> cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve

请注意运行模式下,因日志输出、sourcemap以及未压缩源码等原因,性能和包体积,均不及发行模式。
 INFO  Starting development server...
 ERROR  Error: 

Vue packages version mismatch:

- vue@2.6.11 (/home/passion/Downloads/test/node_modules/vue/dist/vue.runtime.common.js)
- vue-template-compiler@2.6.10 (/home/passion/Downloads/test/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-template-compiler/package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

Error: 

Vue packages version mismatch:

- vue@2.6.11 (/home/passion/Downloads/test/node_modules/vue/dist/vue.runtime.common.js)
- vue-template-compiler@2.6.10 (/home/passion/Downloads/test/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-template-compiler/package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

    at Object.<anonymous> (/home/passion/Downloads/test/node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-template-compiler/index.js:10:9)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/passion/Downloads/test/node_modules/@dcloudio/uni-template-compiler/lib/index.js:11:5)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at getPlatformCompiler (/home/passion/Downloads/test/node_modules/@dcloudio/uni-cli-shared/lib/platform.js:494:14)
    at /home/passion/Downloads/test/node_modules/@dcloudio/vue-cli-plugin-uni/lib/vue-loader.js:31:17
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@0.1.0 dev:h5: `cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test@0.1.0 dev:h5 script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/passion/.npm/_logs/2019-12-15T01_14_54_651Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

# passion @ pchome in ~/Downloads/test on git:master o [9:14:54] C:1
$ 

[或者可以直接贴源代码]

预期结果 [正常运行]

实际结果 [见上面]

系统信息:

补充信息 [可选] [根据你的分析,出现这个问题的原因可能在哪里?]

难道不支持vue cli 4.x ???

passioncsu commented 4 years ago

找到了文档了 确实必须是vue cli 3.x

Jonny-china commented 4 years ago

image 我跟你遇到一样的问题,不是不支持vuecli4.x 而是vue昨天更新了一个小版本,uniapp中的vue-template-compiler 版本没有更新,把VUE版本固定2.6.10,应该是可以的

passioncsu commented 4 years ago

image 我跟你遇到一样的问题,不是不支持vuecli4.x 而是vue昨天更新了一个小版本,uniapp中的vue-template-compiler 版本没有更新,把VUE版本固定2.6.10,应该是可以的

我也发现就算是3.x也是有问题的。 多谢,我也还是用回2.6.10吧