{"id":6543,"date":"2019-10-01T12:22:55","date_gmt":"2019-10-01T03:22:55","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=6543"},"modified":"2019-12-06T16:31:41","modified_gmt":"2019-12-06T07:31:41","slug":"react%e3%81%a7%e3%80%8ccant-import-the-named-export-from-non-ecmascript-module-%e3%80%8d%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%8c%e3%81%a7%e3%82%8b%e6%99%82%e3%81%ae%e5%af%be%e5%bf%9c","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/troubleshooting\/6543","title":{"rendered":"React\u3067\u300cCan&#8217;t import the named export &#8216;***&#8217; from non EcmaScript module \u300d\u30a8\u30e9\u30fc\u304c\u3067\u308b\u6642\u306e\u5bfe\u5fdc"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/09\/failed2compile20191001.png\" alt=\"\" width=\"661\" height=\"160\" class=\"aligncenter size-full wp-image-6545\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/09\/failed2compile20191001.png 661w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/09\/failed2compile20191001-300x73.png 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/p>\n<p>create-react-app\u3092\u4f7f\u3063\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u3044\u308b\u3068\u304d\u3001\u4e00\u90e8\u306e\u5916\u90e8\u30e9\u30a4\u30d6\u30e9\u30ea\u3092import\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:sh decode:true \" >.\/node_modules\/***\/*****\/****.mjs\nCan't import the named export '***' from non EcmaScript module (only default export is available)<\/pre>\n<h2>\u6982\u8981<\/h2>\n<p>\u8abf\u3079\u3066\u307f\u305f\u3068\u3053\u308d\u3001create-react-app\u304cwebpack ver.4\u3092\u4f7f\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u5916\u90e8\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u542b\u307e\u308c\u308b<code>.mjs<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30ed\u30fc\u30c9\u3057\u3088\u3046\u3068\u3057\u3066\u767a\u751f\u3057\u3066\u3044\u308b\u30a8\u30e9\u30fc\u306e\u3088\u3046\u3067\u3059\u3002<br \/>\n\u81ea\u5206\u306e\u74b0\u5883\u3067\u306f\u3001<a href=\"https:\/\/turfjs.org\/\">turf.js<\/a> \u3092import\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001<code>index.mjs<\/code>\u3082\u540c\u6642\u306b\u8aad\u307f\u8fbc\u3093\u3067\u3057\u307e\u3044\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002<br \/>\n\u5384\u4ecb\u306a\u3053\u3068\u306b\u3001turf.js\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b <a href=\"https:\/\/nebula.gl\/\">nebula.gl<\/a> \u3084 <a href=\"https:\/\/github.com\/urbica\/react-map-gl-draw\">react-map-gl-draw<\/a> \u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3082\u540c\u69d8\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h2>\u56de\u907f\u7b56<\/h2>\n<p>\u6839\u672c\u7684\u306a\u89e3\u6c7a\u306b\u306f\u81f3\u308a\u307e\u305b\u3093\u304c\u3001<a href=\"https:\/\/github.com\/timarney\/react-app-rewired\">react-app-rewired<\/a>\u3092\u5229\u7528\u3057\u3066\u3001create-react-app\u306e<code>webpack.config<\/code>\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u5bfe\u5fdc\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>react-app-rewired\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ul>\n<pre class=\"lang:sh decode:true \" >yarn add react-app-rewired<\/pre>\n<ul>\n<li>packge.json\u306enpm script\u3092react-app-rewired\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u66f8\u304d\u63db\u3048<\/li>\n<\/ul>\n<pre class=\"lang:js decode:true \" title=\"package.json\" >    \"scripts\": {\n        \"start\": \"react-app-rewired start\",\n        \"build\": \"react-app-rewired build\",\n        \"test\": \"react-app-rewired test\",\n        \"eject\": \"react-scripts eject\"\n    },<\/pre>\n<ul>\n<li>config-overrides.js\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001webpackConfig.module.rules\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b<\/li>\n<\/ul>\n<pre class=\"lang:js decode:true \" title=\"config-overrides.js\" >module.exports = function override(webpackConfig) {\n    webpackConfig.module.rules.push({\n        test: \/.mjs$\/,\n        include: \/node_modules\/,\n        type: 'javascript\/auto'\n    });\n\n    return webpackConfig;\n};\n<\/pre>\n<p>\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n<p>\u53c2\u8003<br \/>\n<a href=\"https:\/\/github.com\/reactioncommerce\/reaction-component-library\/issues\/399#issuecomment-467860022\">Can&#8217;t import the named export &#8216;Component&#8217; from non EcmaScript module \u00b7 Issue &#35;399 \u00b7 reactioncommerce\/reaction&#45;component&#45;library<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>create-react-app\u3092\u4f7f\u3063\u3066\u30a2\u30d7\u30ea\u30b1\u30fc&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6545,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,19],"tags":[],"class_list":["post-6543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react","category-troubleshooting","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=6543"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6543\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/6545"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=6543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=6543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=6543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}