[英]Module not found: Can't resolve '@babel/runtime/core-js/array/from'
[英]Module not found: Error: Can't resolve 'core-js/fn/array' React Webpack
我將 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 未找到模塊:錯誤:無法解析“C:\\Users\\Ora Ora\\l-3afya-mafya-merch-store-”中的“core-js/fn/array” react-js-\\src\\components\\routes'
也收到這個錯誤
來自 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.