脚手架工具报错 => Can't resolve 'core-js/modules/es6.function.name'
来源:2-6 解构赋值
THEEND0123
2020-11-19
执行如下代码 =>
let {name, age = 18} = {
name: "xxx",
age: 28
}
console.log(name, age)
报错 =>
i 「wds」: Project is running at http://localhost:8080/
i 「wds」: webpack output is served from undefined
i 「wds」: Content not from webpack is served from H:\ld\task\code\ECMScript\mk02\es-demo
WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.
You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:
npm install --save core-js@2 npm install --save core-js@3
yarn add core-js@2 yarn add core-js@3
(node:17604) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(Use `node --trace-deprecation ...` to show where the warning was created)
× 「wdm」: assets by path static/ 15.1 KiB
asset static/favicon.ico 13.3 KiB [emitted] [from: static/favicon.ico] [copied]
asset static/1-1.js 1.07 KiB [emitted] [from: static/1-1.js] [copied]
asset static/1-2.js 750 bytes [emitted] [from: static/1-2.js] [copied]
asset index.js 896 KiB [emitted] (name: main)
asset index.html 310 bytes [emitted]
runtime modules 704 bytes 4 modules
modules by path ./node_modules/ 330 KiB
modules by path ./node_modules/webpack-dev-server/client/ 20.9 KiB 10 modules
modules by path ./node_modules/html-entities/lib/*.js 57.9 KiB 4 modules
modules by path ./node_modules/webpack/hot/ 1.58 KiB 3 modules
modules by path ./node_modules/url/ 37.4 KiB 3 modules
modules by path ./node_modules/querystring/*.js 4.51 KiB
./node_modules/querystring/index.js 127 bytes [built] [code generated]
./node_modules/querystring/decode.js 2.34 KiB [built] [code generated]
./node_modules/querystring/encode.js 2.04 KiB [built] [code generated]
modules by path ./src/*.js 1.34 KiB
./src/index.js 98 bytes [built] [code generated]
./src/1-3.js 1.25 KiB [built] [code generated]
ERROR in ./src/1-3.js 1:0-43
Module not found: Error: Can't resolve 'core-js/modules/es6.function.name' in 'H:\ld\task\code\ECMScript\mk02\es-demo\src'
@ ./src/index.js 4:0-15
webpack 5.4.0 compiled with 1 error in 1888 ms
i 「wdm」: Failed to compile.
npm i -D core-js@2
es-demo\build\webpack.base.config.js
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
"useBuiltIns": "usage"
}]
],
plugins: [[
'@babel/plugin-transform-runtime',
{
corejs: { version: 2 } // 指定 runtime-corejs 的版本,目前有 2 3 两个版本
}
]]
}
}
}]
},
写回答
1回答
-
谢成
2020-11-20
学习笔记建议直接写在笔记功能当中,便于管理和查找。
00
相似问题