Error: 'You may need an appropriate loader to handle this file type' when building react-static site

Error: 'You may need an appropriate loader to handle this file type' when building react-static site

我在使用 react-static 构建站点时遇到此错误:

ERROR in ERROR in C:/Users/.../test/artifacts/react-static-templates.js 1:1016 C:/Users/.../test/artifacts/react-static-templates.js 1:1016 Module parse failed: Unexpected token (1:1016) You may need an appropriate loader to handle this file type.

网站刚刚创建。我可以 运行 但我无法为部署构建。

这似乎是 babel loader 的问题,但我对 react-static 架构的了解还不够,无法修复它。

这里是我认为可能相关的配置文件:

文件:.babelrc

{
  "presets": ["react-static/babel-preset.js"]
}

文件:.eslintrc.js

module.exports = {
  extends: 'react-tools',
}

文件:package.json

{
  "name": "react-static-example-basic",
  "private": true,
  "scripts": {
    "start": "react-static start",
    "stage": "react-static build --staging",
    "build": "react-static build",
    "bundle": "react-static bundle",
    "export": "react-static export",
    "serve": "serve dist -p 3000 -s"
  },
  "dependencies": {
    "@reach/router": "^1.2.1",
    "axios": "^0.18.0",
    "react": "^16.8.1",
    "react-dom": "^16.8.1",
    "react-hot-loader": "^4.3.12",
    "react-static": "^6.0.18"
  },
  "devDependencies": {
    "eslint-config-react-tools": "1.x.x",
    "serve": "10.1.1"
  }
}

环境:

2019-03-16更新:

略有进步。发现这个关闭的 issue 完全匹配这个错误。

应用修复后,静态模板的构建仍然失败,但现在出现错误消息:

ERROR in .../artifacts/react-static-templates.js
Module build failed (from ./babel-loader/lib/index.js):
TypeError: Cannot read property 'replace' of undefined

我通过清理完整的 nodejs 环境并重新安装它解决了 mac 上的问题。

Here步骤。 看看评论也是。 可以评论多几步