简体   繁体   English

找不到模块:错误:无法解析“core-js/fn/array”React Webpack

[英]Module not found: Error: Can't resolve 'core-js/fn/array' React Webpack

I changed CollectionPage's component to arrow function component rather than just normal function and then I got this error but I don't know why it didn't threw this error when I did the same with a lot of other components .我将 CollectionPage 的组件更改为箭头函数组件,而不仅仅是普通函数,然后出现此错误,但我不知道为什么当我对许多其他组件执行相同操作时它没有抛出此错误。 this the comonent code这是组件代码

import { from } from 'core-js/fn/array'
import React from 'react'
import { useParams } from 'react-router-dom'
import Products from '../Products/Products'
import {H1} from '../../Style/global'

const CollectionPage=()=> {
    const {collectionTitle}= useParams()
    return (
        <div style={{marginTop:96}}>
            <H1>{collectionTitle} Collection</H1>
            <Products collectionTitle={collectionTitle}/>
        </div>
    )
}


export default CollectionPage

btw this a react webpack project and here is my webpack config :顺便说一句,这是一个 react webpack 项目,这是我的 webpack 配置:

const path = require('path')
const HTMLPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin');

module.exports ={
    entry :"./src/index.js",
    output:{
        path:path.resolve(__dirname,"./dist"),
        filename:'index.js',
    },
    plugins:[
        new HTMLPlugin({template:'./src/index.html'}),
        new CopyPlugin({
            patterns: [
              { from: './src/images', to: 'images' },
            ],
          }),
    ],
    module:{
        rules:[
            { 
                test : /\.js$/,
                exclude:/node_modules/,
                use:{
                    loader:"babel-loader"
                },
            },
            {
                test: /\.(png|gif|jpg)$/,
                include: [
                  path.join(__dirname, './src/images')
                ],
                loader: 'file-loader',
             },
            {
                test:/.(png|jpg|woff|woff2|eot|ttf|svg|gif)$/, //Customise according to your need
                use: [
                  {
                    loader: 'url-loader',
                    options: {
                      limit: 100000000,
                    }
                  }
               ]
            },
            {
                test: /\.js$/,
                enforce: 'pre',
                use: ['source-map-loader'],
            },
            {
                test: /\.css$/i,
                loader: 'style-loader!css-loader' 
            },
        ]
    }
}

this is the error :这是错误:

./src/components/routes/CollectionPage.js Module not found: Error: Can't resolve 'core-js/fn/array' in 'C:\\Users\\Ora Ora\\l-3afya-mafya-merch-store-react-js-\\src\\components\\routes' ./src/components/routes/CollectionPage.js 未找到模块:错误:无法解析“C:\\Users\\Ora Ora\\l-3afya-mafya-merch-store-”中的“core-js/fn/array” react-js-\\src\\components\\routes'

also getting this error也收到这个错误

Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\DumpStack.log.tmp' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\hiberfil.sys' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\pagefile.sys' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\swapfile.sys' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\DumpStack.log.tmp' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\hiberfil.sys' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\pagefile.sys' Error from chokidar (C:\\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\\swapfile.sys'来自 chokidar (C:\\node_modules) 的错误:错误:EBUSY:资源繁忙或锁定,lstat 'C:\\DumpStack.log.tmp' 来自 chokidar (C:\\node_modules) 的错误:错误:EBUSY:资源繁忙或锁定,lstat来自 chokidar (C:\\node_modules) 的“C:\\hiberfil.sys”错误:错误:EBUSY:资源繁忙或锁定,来自 chokidar (C:\\node_modules) 的 lstat 'C:\\pagefile.sys' 错误:错误:EBUSY:资源繁忙或锁定,来自 chokidar (C:\\node_modules) 的 lstat 'C:\\swapfile.sys' 错误:错误:EBUSY:资源繁忙或锁定,lstat 'C:\\DumpStack.log.tmp' 来自 chokidar 的错误 (C: \\node_modules): 错误: EBUSY: 资源繁忙或锁定, lstat 'C:\\hiberfil.sys' 来自 chokidar 的错误 (C:\\node_modules): 错误: EBUSY: 资源繁忙或锁定, lstat 'C:\\pagefile.sys'来自 chokidar (C:\\node_modules) 的错误:错误:EBUSY:资源繁忙或锁定,lstat 'C:\\swapfile.sys'

感谢 Jacobo Tapia 的评论,我意识到这是一个愚蠢的 Visual Studio 自动导入错误,因为您可以在我的组件顶部看到这个 import import { from } from 'core-js/fn/array'这没有任何意义

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块:无法解析“ @ babel / runtime / core-js / array / from” - Module not found: Can't resolve '@babel/runtime/core-js/array/from' 如何解决找不到模块:无法在 Material-UI 中解析“@babel/runtime/core-js/map” - How to solve Module not found: Can't resolve '@babel/runtime/core-js/map' in Material-UI 无法使用Material-UI进行编译:找不到模块:无法解析&#39;@ babel / runtime / core-js / object / get-prototype-of&#39; - Unable to compile using Material-UI: Module not found: Can't resolve '@babel/runtime/core-js/object/get-prototype-of' 找不到模块:错误:无法在 webpack.common.js 中解析 - Module not found: Error: Can't resolve in webpack.common.js Webpack:移动 webpack/react 文件的位置后,npm start “Module not found: Error: Can&#39;t resolve ...” - Webpack: npm start "Module not found: Error: Can't resolve ..." after moving location for webpack / react files 找不到模块:错误:无法解析 React-js? - Module not found: Error: Can't resolve React-js? 使用Webpack,Babel和React进行生产构建时出错-错误:找不到模块&#39;@ babel / runtime / core-js / get-iterator&#39; - Error in production build with Webpack, Babel and React - Error: Cannot find module '@babel/runtime/core-js/get-iterator' React 和 core-js 不能为 IE10 填充 - React and core-js can't polyfill for IE10 找不到模块:错误:无法解析“反应” - Module not found: Error: Can't resolve 'react' 找不到模块:错误:无法解析“ react-hot-loader / webpack” - Module not found: Error: Can't resolve 'react-hot-loader/webpack'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM