question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onPostBuild lifecycle event doesn't exist

See original GitHub issue

Describe the bug

I receive the following error when using a simple Netlify build plugin with the onPostBuild lifecycle handler. I have been testing with the official sitemap plugin.

Error: Invalid lifecycle hook 'onPostBuild'.
Please use a valid event name. One of:
"init", "preGetCache", "getCache", "postGetCache", "preInstall", "install", "postInstall", "preBuild", "preFunctionsBuild", "functionsBuild", "postFunctionsBuild", "build", "postBuild", "prePackage", "package", "postPackage", "preDeploy", "preSaveCache", "saveCache", "postSaveCache", "finally", "onError"

Steps to reproduce

Environment:

> netlify --version
netlify-cli/2.25.0 darwin-x64 node-v12.11.0

I am using the latest version of Netlify Cli cloned from git and using npm link so it can be used globally.

Install the netlify-plugin-sitemap into a project or use the basic plugin code below and then run netlify build, this command should throw the error.

module.exports = {
  name: '@netlify/plugin-http2',
  onPostBuild: async ({ constants, pluginConfig }) => {
    console.log('POST BUILD');
  }
};

Expected behavior

It should not report an error and the lifecycle event should be called at the correct point in the build. I assume this lifecycle method still exists as it is in the README.

Environment

npx: installed 1 in 3.39s

  System:
    OS: macOS 10.15.2
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 51.02 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.11.0 - ~/.nvm/versions/node/v12.11.0/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.11.0/bin/npm

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
oscartbeaumontcommented, Dec 19, 2019

Sorry to waste your time, after clearing node_modules and package-lock.json and reinstalling everything has started working.

0reactions
ehmickycommented, Dec 19, 2019

No worries! Feel free to post any issues you might encounter 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

error "gatsby-plugin-manifest" threw an error while running the ...
Failed at the gatsby-starter-default@0.1.0 build script. 20:49:09.617 | npm ERR! This is probably not a problem with npm. There is likely ...
Read more >
Gatsby Node APIs
You can use its APIs to create pages dynamically, add data into GraphQL, or respond to events during the build lifecycle. To use...
Read more >
Apollo Server plugin event reference - Apollo GraphQL Docs
This reference describes the lifecycle events that your custom Apollo Server plugin ... The server doesn't start until this asynchronous method completes.
Read more >
App lifecycle - .NET MAUI | Microsoft Learn
NET MAUI raises cross-platform lifecycle events when an app transitions between its different execution states.
Read more >
Activity | Android Developers
On this page; Developer Guides; Fragments; Activity Lifecycle; Configuration Changes ... Returns. Object, The service or null if the name does not exist....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found