
あきぞらです。
Vue.jsのプロジェクトを作ろうとして、npm run build
を実行したら、表題のエラーがでました。
ハマりかけましたが、意外とすぐに解決できたのでその方法を紹介したいと思います。
事象
npm
のプロジェクトを作成し、npm run build
を実行したところ、以下のようなエラーが。
$ npm run build ... ... ⠹ Building for production... ERROR Failed to compile with 13 errors These dependencies were not found: * core-js/modules/es6.array.find-index in ./src/components/... * core-js/modules/es6.array.iterator in ./node_modules/... * core-js/modules/es6.number.constructor in ./node_modules/... * .... * ....
何か設定をミスったかと思いソースコードを調べてみるも、わからずじまいでした。
原因と解消方法
調べると、どうもcore-js
のバージョン周りが怪しいらしいです。
GitHub
Can't start Nuxt after 2.5.0 release due to missing dependencies (core-j...
Version v2.5.0 Node Version v8.14.0 Reproduction link http:\no-reproduction-link.com ps: I'll try to provide an example as soon as posible Steps to reproduce Just Execute: $ yarn dev What is expect...
バージョン2系のcore-jsをインストールする必要がありそうでした。
ということで、インストールしてみます。
$ npm add core-js@2
再度npm run build
してみると...動きました。
package.json
のバージョンも確認して問題ないことをチェックします。
"dependencies": { "bootstrap": "^4.3.1", "chartist": "^0.11.0", "core-js": "^2.6.11", "core.js": "^0.4.2", "google-maps": "^3.2.1", "register-service-worker": "^1.5.2", "v-tooltip": "^2.0.0-rc.33", "vue": "^2.6.6", "vue-router": "^3.0.2", "vue2-google-maps": "^0.8.4" },
バージョンが2系になっていますね。
特殊な状況の場合の方が多いかもしれませんが、バージョンを下げることも一案です。
では、また。