LoginSignup
4
1

More than 3 years have passed since last update.

vue create で作成したプロジェクトでコンパイルエラーが発生した場合

Last updated at Posted at 2020-01-19

vue createでプロジェクトを作成

vue create my-project

質問をマニュアルで進め、無事プロジェクトの作成に成功したので開発サーバーを起動します。

cd my-project
npm run serve

エラー発生

すると、次のようなエラーが

 ERROR  Failed to compile with 1 errors                                         

error  in ./src/main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] <project-path>/my-project/src/main.js: Package exports for 
'<project-path>my-project/node_modules/@babel/helper-compilation-targets'
do not define a '.' subpath (While processing: 
"<project-path>/my-project/node_modules/@vue/cli-plugin-babel/preset.js")

解決策

Node.jsのバージョンを13.2.0以上にあげる必要があります。

Node.jsのバージョンを上げる方法

nをインストール

Node.jsのバージョン管理ツールであるnをインストールします。

npm install -g n

最新バージョンを確認

n --stableで安定版、n --latestで最新版を確認できます。
2019/1/20 現在の実行結果です。

n --stable
12.14.1
n --latest
13.6.0

最新版をインストール

n latest

sudoが要求されたら、sudo n latestのようにして実行してください。

インストールされたかバージョンを確認します。

node -v

もう一度プロジェクトを作成。無事解決することができました。
スクリーンショット 2020-01-19 17.18.50 1.png

参考サイト

Error: Package exports for /node_modules/@babel/helper-compilation-targets' do not define a '.' subpath
Node.jsとnpmをアップデートする方法 | Rriver

4
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
4
1