构建项目时会发生此错误。
我认为这是因为我没有 react-static 构建,但我不知道错误。
包.json
"dependencies": {
"@reach/router": "^1.2.1",
"aos": "^2.3.4",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-router-dom": "^5.1.2",
"react-static": "^7.2.0",
"react-static-plugin-reach-router": "^7.2.0",
"react-static-plugin-sass": "^7.2.2",
"react-static-plugin-sitemap": "^7.2.0",
"react-static-plugin-source-filesystem": "^7.2.0",
....
},
构建命令: 纱线构建
(但 react-static build 命令是react-static build)
错误
ReferenceError: Failed exporting HTML for URL / (/Users/youj/projects/project_name/src/pages/index.js): document is not defined
- aos.js:1 n
[project_name]/[aos]/dist/aos.js:1:14577
- aos.js:1 Object._ [as init]
[project_name]/[aos]/dist/aos.js:1:1530
- static-app.js:1850 MainFunction
/Users/youj/projects/project_name/artifacts/static-app.js:1850:26
- react-dom-server.node.production.min.js:36 d
[project_name]/[react-dom]/cjs/react-dom-server.node.production.min.js:36:498
- react-dom-server.node.production.min.js:39 Za
[project_namee]/[react-dom]/cjs/react-dom-server.node.production.min.js:39:16
- react-dom-server.node.production.min.js:44 a.b.render
[project_name]/[react-dom]/cjs/react-dom-server.node.production.min.js:44:476
- react-dom-server.node.production.min.js:44 a.b.read
[project_name]/[react-dom]/cjs/react-dom-server.node.production.min.js:44:18
- react-dom-server.node.production.min.js:54 renderToString
[project_name]/[react-dom]/cjs/react-dom-server.node.production.min.js:54:364
- exportRoute.js:137 renderToStringAndExtract
[project_name]/[react-static]/src/static/exportRoute.js:137:21
- exportRoute.js:194 _callee$
[project_name]/[react-static]/src/static/exportRoute.js:194:15
树
├──src
├──index.js (render app.js)
├── pages
│ ├── 404.js
│ └── index.js (call view components)