0

我在 package.json 中设置了以下配置:

"reactSnap": {
    "inlineCss": true,
    "puppeteerArgs": ["--no-sandbox", "--disable-setuid-sandbox"],
    "puppeteerExecutablePath": "/opt/google/chrome/google-chrome",
    "skipThirdPartyRequests": true
}

然而,当yarn build抛出此消息时。

 console.log at /: 
          There has been an Error with loading Google Maps API script, please check that you provided correct google API key (-) or Client ID (-) to <LoadScript />
          Otherwise it is a Network issue.

我想知道为什么 react-snap 会调用 Google Maps API,因为skipThirdPartyRequests: true.

完整日志在这里:

$ yarn build
yarn run v1.22.5
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  172.66 KB  build/static/js/4.c46b6531.chunk.js
  88.24 KB   build/static/js/6.1bcef16a.chunk.js
  35.95 KB   build/static/js/7.d6959317.chunk.js
  29.21 KB   build/static/js/0.ef536f71.chunk.js
  26.45 KB   build/static/js/15.2316ab4a.chunk.js
  17.83 KB   build/static/js/8.a79b17ce.chunk.js
  13.78 KB   build/static/js/13.80f7af18.chunk.js
  10.22 KB   build/static/js/5.8271c8dc.chunk.js
  9.15 KB    build/static/js/main.4c7512d6.chunk.js
  7.63 KB    build/static/js/9.e7e9403e.chunk.js
  6.81 KB    build/static/js/14.9ff106e9.chunk.js
  6.19 KB    build/static/js/16.f2b51ab6.chunk.js
  5.8 KB     build/static/js/18.3b03d045.chunk.js
  4.15 KB    build/static/js/22.48119aa4.chunk.js
  4.11 KB    build/static/js/17.f74fa8b9.chunk.js
  3.24 KB    build/static/js/21.7472a414.chunk.js
  3.11 KB    build/static/js/23.3df8be71.chunk.js
  2.88 KB    build/static/js/11.70cb0d87.chunk.js
  2.31 KB    build/static/css/4.15b9c088.chunk.css
  2.21 KB    build/static/js/10.50710830.chunk.js
  1.82 KB    build/static/js/20.1941d315.chunk.js
  1.79 KB    build/static/js/12.f02e3f24.chunk.js
  1.76 KB    build/static/js/runtime-main.be714a25.js
  1.61 KB    build/static/css/main.acaac1c2.chunk.css
  1016 B     build/static/js/19.59a05dae.chunk.js
  700 B      build/static/js/1.8c9aa125.chunk.js
  563 B      build/static/css/19.48448327.chunk.css
  376 B      build/static/css/20.3a697ef5.chunk.css
  293 B      build/static/css/22.70cd7bae.chunk.css
  273 B      build/static/css/21.df71685a.chunk.css
  217 B      build/static/js/24.9ae44ea9.chunk.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

$ react-snap
  console.log at /: Failed to load resource: net::ERR_FAILED
  console.log at /: Failed to load resource: net::ERR_FAILED
  console.log at /: Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables
  console.log at /: Failed to load resource: net::ERR_FAILED
  console.log at /: Failed to load resource: net::ERR_FAILED
  console.log at /: injectScript error:  JSHandle@object
  console.log at /: 
          There has been an Error with loading Google Maps API script, please check that you provided correct google API key (-) or Client ID (-) to <LoadScript />
          Otherwise it is a Network issue.
        
  console.log at /: Failed to load resource: net::ERR_FAILED
  error at / Error: Evaluation failed: TypeError: Failed to fetch
    at ExecutionContext._evaluateInternal (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/ExecutionContext.js:48:12)
    at async inlineCss (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/index.js:280:18)
    at async afterFetch (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/index.js:685:30)
    at async fetchPage (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/src/puppeteer_utils.js:244:24)
  -- ASYNC --
    at ExecutionContext.<anonymous> (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/helper.js:111:15)
    at DOMWorld.evaluate (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/DOMWorld.js:112:20)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  -- ASYNC --
    at Frame.<anonymous> (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.evaluate (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/Page.js:833:43)
    at Page.<anonymous> (/home/hnhegde/work/square-deal-ui/node_modules/puppeteer/lib/helper.js:112:23)
    at inlineCss (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/index.js:280:29)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async afterFetch (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/index.js:685:30)
    at async fetchPage (/home/hnhegde/work/square-deal-ui/node_modules/react-snap/src/puppeteer_utils.js:244:24)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ 
$ 
$ 
4

0 回答 0