Quoted from this article:
Because SharePoint Online and SharePoint 2016 have different release
cycles for new capabilities, they also have different capabilities
when it comes to the SharePoint Framework. SharePoint Online always
uses the latest version of the SharePoint Framework, but SharePoint
2016 only supports the version that matches the server-side
dependencies of the deployed packages.
SharePoint 2016 Feature Pack 2 supports SharePoint Framework
client-side web parts hosted on classic SharePoint pages built by
using the SharePoint Framework v1.1.0. This means that when you are
targeting the SharePoint 2016 platform, you need to use the SharePoint
Framework v1.1.0 due to the server-side version dependencies.
If you are planning to use the same client-side web parts in both
SharePoint 2016 and in SharePoint Online, you need to use the
SharePoint Framework v1.1.0 as your baseline version to ensure that
the web part works in both environments.
Starting from version 1.3, the SharePoint Framework Yeoman generator
supports scaffolding solutions that use both the latest version of the
SharePoint Framework meant for use with SharePoint Online, and
solutions that can be used with SharePoint on-premises based on the
v1.1.0 of the SharePoint Framework. You don't need to install a
separate version of the SharePoint Framework Yeoman generator to
scaffold solutions meant for use with SharePoint on-premises.
More information is here: