2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

yarn serveした時に「Cannot find module 'vue-template-compiler'」の対処法

Posted at

vueプロジェクトを新規作成してyarn serveしようとした時、エラーになったので対処法のメモ書きです。

エラー内容

 ERROR  Error: Cannot find module 'vue-template-compiler'
Require stack:
- ~/node_modules/@vue/cli-plugin-typescript/lib/tslint.js
- ~/node_modules/@vue/cli-plugin-typescript/generator/index.js
- ~/package.json
Error: Cannot find module 'vue-template-compiler'
Require stack:
- ~/node_modules/@vue/cli-plugin-typescript/lib/tslint.js
- ~/node_modules/@vue/cli-plugin-typescript/generator/index.js
- ~/package.json
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (~/node_modules/@vue/cli-plugin-typescript/lib/tslint.js:7:21)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)

対処方法

cliで使うパッケージが不足していたみたいなので、追加で@vue/compiler-sfcを入れます。
FYI: Cannot find module 'vue-template-compiler/package.json' | GitHub

yarn

yarn global add @vue/compiler-sfc

npm

npm i -g @vue/compiler-sfc
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?