Netlify gastby build fails

Please help, my site fails on OnPostBuild. I tried it all and searched the deep corners of the web and nothing seems to work. Thank you

  • Site name silly-ptolemy-9a28a6.netlify.app
────────────────────────────────────────────────────────────────
  Netlify Build                                                 
────────────────────────────────────────────────────────────────
​
❯ Version
  @netlify/build 18.21.4
​
❯ Flags
  dry: false
  offline: false
​
❯ Current directory
  /repo
​
❯ Config file
  /repo/netlify.toml
​
❯ Context
  production
​
❯ Loading plugins
   - @netlify/plugin-gatsby@1.0.3 from Netlify app and package.json
​
────────────────────────────────────────────────────────────────
  1. @netlify/plugin-gatsby (onPreBuild event)                  
────────────────────────────────────────────────────────────────
​
No Gatsby cache found. Building fresh.
Add `gatsby-plugin-netlify` to `gatsby-config.js` if you would like to support Gatsby redirects. 🎉
​
(@netlify/plugin-gatsby onPreBuild completed in 194ms)
​
────────────────────────────────────────────────────────────────
  2. build.command from netlify.toml                            
────────────────────────────────────────────────────────────────
​
$ yarn run build
yarn run v1.22.17
$ gatsby build
success open and validate gatsby-configs, load plugins - 1.772s
success onPreInit - 0.049s
success initialize cache - 0.032s
success copy gatsby files - 0.269s
success Compiling Gatsby Functions - 0.295s
success onPreBootstrap - 0.315s
success createSchemaCustomization - 0.036s
success Checking for changed pages - 0.002s
success source and transform nodes - 1.352s
success building schema - 0.557s
success createPages - 0.004s
success createPagesStatefully - 0.114s
info Total nodes: 67, SitePage nodes: 13 (use --verbose for breakdown)
success Checking for changed pages - 0.000s
success update schema - 0.075s
success onPreExtractQueries - 0.000s
success extract queries from components - 2.010s
warn There are routes that match both page and redirect. It will result in page
not being accessible; this is probably not intentional:
 - page: "/" and redirect: "/" -> "/sign-in"
success write out redirect data - 0.153s
success Build manifest and related icons - 0.143s
success onPostBootstrap - 0.147s
info bootstrap finished - 11.397s
success run static queries - 0.013s - 2/2 159.92/s
success run page queries - 0.006s - 13/13 2045.88/s
success write out requires - 0.006s
success Building production JavaScript and CSS bundles - 41.191s
success Rewriting compilation hashes - 0.038s
success Writing page-data.json files to public directory - 0.178s - 13/13
73.18/s
success Building HTML renderer - 8.788s
success Building static HTML for pages - 0.456s - 13/13 28.50/s
success onPostBuild - 0.028s
success Caching JavaScript and CSS webpack compilation - 19.759s
success Caching HTML renderer compilation - 12.363s
info Done building in 74.119228441 sec

✨  Done in 75.26s.
​
(build.command completed in 1m 15.6s)
​
────────────────────────────────────────────────────────────────
  3. @netlify/plugin-gatsby (onBuild event)                     
────────────────────────────────────────────────────────────────
​
​
(@netlify/plugin-gatsby onBuild completed in 961ms)
​
────────────────────────────────────────────────────────────────
  4. Functions bundling                                         
────────────────────────────────────────────────────────────────
​
Packaging Functions from netlify/functions directory:
 - gatsby/gatsby.js
​
​
(Functions bundling completed in 781ms)
​
────────────────────────────────────────────────────────────────
  5. @netlify/plugin-gatsby (onPostBuild event)                 
────────────────────────────────────────────────────────────────
​
​
────────────────────────────────────────────────────────────────
  Plugin "@netlify/plugin-gatsby" internal error                
────────────────────────────────────────────────────────────────
​
  Error message
  Error: Cannot cache /repo because it is the current directory (repo) or a parent directory
​
  Plugin details
  Package:        @netlify/plugin-gatsby
  Version:        1.0.3
  Repository:     git+https://github.com/netlify/netlify-plugin-gatsby.git
  npm link:       https://www.npmjs.com/package/@netlify/plugin-gatsby
  Report issues:  https://github.com/netlify/netlify-plugin-gatsby/issues
​
  Error location
  In "onPostBuild" event in "@netlify/plugin-gatsby" from Netlify app and package.json
      at checkSrcPath (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/cache-utils/src/path.js:46:11)
      at getSrcPath (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/cache-utils/src/path.js:20:3)
      at async parsePath (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/cache-utils/src/path.js:11:19)
      at async saveOne (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/cache-utils/src/main.js:18:34)
      at async Promise.all (index 0)
      at async allowMany (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/cache-utils/src/main.js:85:19)
      at async onPostBuild (repo/node_modules/@netlify/plugin-gatsby/src/index.js:132:9)
      at async Object.run (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/run.js:20:3)
      at async handleEvent (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/child/main.js:36:38)
      at async process.<anonymous> (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/build/src/plugins/ipc.js:103:16)
​
  Resolved config
  build:
    command: yarn run build
    commandOrigin: config
    environment:
      - NODE_VERSION
    publish: repo
    publishOrigin: default
  functionsDirectory: repo/netlify/functions 

Hi @Katgistus,

Could you try building on Netlify instead of Netlify CLI to see if the error is the same?

Hello @hrishikesh, thank you for replying.

The reason why I’m using it via CLI for continuous delivery is because there are some artifactory logins that need to happen to pull some of the private dependencies in the package.json file.

Would using private modules help:

I am just asking you to try building online so that we can narrow down if the problem is with CLI or the actual build environment.

Hello. I went through the steps and I am still getting the 403 error when deploying using the UI

10:02:56 PM: error An unexpected error occurred: "https://company.jfrog.io/artifactory/api/npm/npm-virtual/@company/service/-/@company/service-1.0.12.tgz: Request failed \"403 Forbidden\"".

10:02:56 PM: info If you think this is a bug, please open a bug report with the information provided in "/opt/build/repo/yarn-error.log".

The error indicates authentication is possibly required to access the resource.

Yes which brings be back to this.

As well as the Support Guide @hrishikesh linked to, have you checked out

And possibly

1 Like

Good news @coelmay and @hrishikesh.

Following @hrishikesh suggestion we created a .npmrc file and injected the NPM_TOKEN that was set on Netlify UI pushed file to master and build and deployed through Netlify UI.
We just need to find a way to do it via the internal pipelines(using CLI).

Thank you all for your speedy assistance! Have a good one :pray:t4:

1 Like