【发布时间】:2020-05-31 02:06:14
【问题描述】:
这是我的代码。我正在使用 VueCLI。
产生问题的行是this.slides.forEach(..
我遇到的错误是dependencies not found(下面是完整错误)。
当我安装缺少npm install --save core-js/modules/es.array.for-each core-js/modules/web.dom-collections.for-each 的依赖项时,出现es.array.for-each does not contain a package.json file 错误
然后我在错误中描述的位置创建了 package.json 文件。我运行npm install 但我有同样的package.json not found 错误。
这里有什么问题的线索吗?
<template>
<div>
<slot>
</slot>
</div>
</template>
<script>
export default {
data (){
return{
index: 0,
slides: []
}
},
mounted(){
this.slides = this.$children
this.slides.forEach((slide, i) => {
slide.index = i
})
}
}
</script>
<style lang="css">
</style>
ERROR Failed to compile with 2 errors 10:39:10 AM
These dependencies were not found:
* core-js/modules/es.array.for-each in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Carousel/Carousel.vue?vue&type=script&lang=js&
* core-js/modules/web.dom-collections.for-each in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Carousel/Carousel.vue?vue&type=script&lang=js&
To install them, you can run: npm install --save core-js/modules/es.array.for-each core-js/modules/web.dom-collections.for-each
npm ERR! code ENOLOCAL
npm ERR! Could not install from "core-js\modules\es.array.for-each" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! User\...\AppData\Roaming\npm-cache\_logs\2020-02-15T15_49_17_958Z-debug.log
【问题讨论】:
标签: javascript npm npm-install vue-cli