Vue-cli: Typescript generator not working

Created on 5 Mar 2018  ·  13Comments  ·  Source: vuejs/vue-cli

Version

3.0.0-beta.3

Reproduction link

https://codesandbox.io/s/kx4k47zlx3

Steps to reproduce

vue create project
vue-router, sass, babel, typescript OR just typescript without anything else

What is expected?

Project to be created

What is actually happening?

Vue CLI v3.0.0-beta.4
? Please pick a preset: Manually select features
? Check the features needed for your project: TS
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript for auto-detected polyfills? Yes
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In dedicated config files

🚀 Invoking generators...
ERROR Error: Cannot find module '@vue/cli-service/generator/template/src/App.vue'
Error: Cannot find module '@vue/cli-service/generator/template/src/App.vue'
at Function.Module._resolveFilename (module.js:536:15)
at Function.resolve (internal/module.js:18:19)
at renderFile (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:226:17)
at _injectFileMiddleware (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:141:27)
at
at process._tickCallback (internal/process/next_tick.js:188:7)


Actually Vue CLI v3.0.0-beta.4, but Version dropdown doesn't offer it.

bug

Most helpful comment

For those writing their own presets or generators.js and facing this error, you do not need to install the @vue/cli-service globally. Just provide it as a devDependencies in your related project.

All 13 comments

Hmm... can't reproduce. Just did a fresh install with what your prompts are and it worked as expected.

It seems @vue/cli-service needs to be installed along otherwise the dependency can't be resolved.

damir@5giga:/app/air$ vue create client


Vue CLI v3.0.0-beta.4
? Please pick a preset: Manually select features
? Check the features needed for your project: TS
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript for auto-detected polyfills? Yes
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? No


Vue CLI v3.0.0-beta.4
✨  Creating project in /app/air/client.
🗃  Initializing git repository...
⚙  Installing CLI plugins. This might take a while...

yarn install v1.0.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.



success Saved lockfile.
Done in 21.40s.

🚀  Invoking generators...
 ERROR  Error: Cannot find module '@vue/cli-service/generator/template/src/App.vue'
Error: Cannot find module '@vue/cli-service/generator/template/src/App.vue'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.resolve (internal/module.js:18:19)
    at renderFile (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:226:17)
    at _injectFileMiddleware (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:141:27)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
damir@5giga:/app/air$ 

Forgot to mention I use Ubuntu 17.10, though not sure that makes a difference. I went to another machine now, installed latest vue-cli (used yarn global add). Exact same issue.
If there is anything else I can do to pinpoint the problem, do let me know.

Yep, I can confirm that sudo yarn global add @vue/cli-service solves the issue.

I get same error @dbulic at "Invoking generators..." I am on Windows 10; used npm

requiring sudo yarn global add @vue/cli-service seems wrong? isn't that what's trying to be avoided by the new version?
seems related to #1105

For those writing their own presets or generators.js and facing this error, you do not need to install the @vue/cli-service globally. Just provide it as a devDependencies in your related project.

For those writing their own presets or generators.js and facing this error, you do not need to install the @vue/cli-service globally. Just provide it as a devDependencies in your related project.

thanks

This is very broken again. I did find the templates in cli-plugin-typescript so have been able to fix myself.

Steps to Create issue:

  1. npm init vite-app
  2. vue add typescript (take all defaults)

Error:

�  Invoking generator for @vue/cli-plugin-typescript...
 ERROR  Error: Cannot find module '@vue/cli-service/generator/template/src/App.vue' from ....

This is very broken again. I did find the templates in cli-plugin-typescript so have been able to fix myself.

☝️ Same here

@jtbaker how did you fix it? i'm facing the same problem and it's very anoying

@rposener same teminal steps and get same error~

I manually installed @vue/cli-service and it is working reference
npm install --save-dev @vue/cli-service

@jtbaker how did you fix it? i'm facing the same problem and it's very anoying

I think I wound up copying over my tsconfig.json package.json and vue.config.js settings from an existing project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NathanKleekamp picture NathanKleekamp  ·  3Comments

JIANGYUJING1995 picture JIANGYUJING1995  ·  3Comments

brandon93s picture brandon93s  ·  3Comments

Akryum picture Akryum  ·  3Comments

Gonzalo2683 picture Gonzalo2683  ·  3Comments