LoginSignup
0
0

More than 3 years have passed since last update.

Webpack5 + TypeScript + Babel(core-js)でCan't resolveエラーが出た場合の対処法

Posted at

環境

"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"babel-loader": "^8.2.2",
"ts-loader": "^8.0.14",
"typescript": "^4.1.3",
"webpack": "^5.14.0"
"core-js": "^3.8.2"

概要

WebpackとBabelでpolyfilをいい感じに使おうとしたら以下のエラーが延々と…

ERROR in ./node_modules/core-js/modules/es.array.for-each.js 2:8-38
Module not found: Error: Can't resolve '../internals/export' in '/Users/s01212/workspace/glasgow-dpa-sdk/node_modules/core-js/modules'
 @ ./src/scripts/Params.ts 1:0-46
 @ ./src/scripts/AmebaDpa.ts 1:0-34 25:4-15 27:8-24 30:6-23
 @ ./src/scripts/index.ts 1:0-38 10:26-34

ERROR in ./node_modules/core-js/modules/es.array.for-each.js 3:14-52
Module not found: Error: Can't resolve '../internals/array-for-each' in '/Users/s01212/workspace/glasgow-dpa-sdk/node_modules/core-js/modules'
 @ ./src/scripts/Params.ts 1:0-46
 @ ./src/scripts/AmebaDpa.ts 1:0-34 25:4-15 27:8-24 30:6-23
 @ ./src/scripts/index.ts 1:0-38 10:26-34

ERROR in ./node_modules/core-js/modules/es.array.iterator.js 2:22-63
Module not found: Error: Can't resolve '../internals/to-indexed-object' in '/Users/s01212/workspace/glasgow-dpa-sdk/node_modules/core-js/modules'
 @ ./src/scripts/Params.ts 2:0-46
 @ ./src/scripts/AmebaDpa.ts 1:0-34 25:4-15 27:8-24 30:6-23
 @ ./src/scripts/index.ts 1:0-38 10:26-34

✨解決

webpack.config.js
  resolve: {
    extensions: [
      '.ts'
    ]
  }

上記に '.js' を追加することで解消!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0