gpt4 book ai didi

reactjs - 找不到模块 : Error: Can't resolve 'core-js/fn/array' React Webpack

转载 作者:行者123 更新时间:2023-12-05 08:30:25 27 4
gpt4 key购买 nike

我将 CollectionPage 的组件更改为箭头函数组件,而不仅仅是普通函数,然后我得到了这个错误,但我不知道为什么当我对很多其他组件做同样的事情时它没有抛出这个错误。这是组件代码

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

顺便说一句,这是一个 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'
},
]
}
}

这是错误:

./src/components/routes/CollectionPage.js Module not found: Error:Can't resolve 'core-js/fn/array' in 'C:\Users\OraOra\l-3afya-mafya-merch-store-react-js-\src\components\routes'

同样出现这个错误

Error from chokidar (C:\node_modules): Error: EBUSY: resource busy orlocked, 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 fromchokidar (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 fromchokidar (C:\node_modules): Error: EBUSY: resource busy or locked,lstat 'C:\swapfile.sys'

最佳答案

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

关于reactjs - 找不到模块 : Error: Can't resolve 'core-js/fn/array' React Webpack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64185993/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com