Error: No valid exports main found for

I am following the Creating Plugins guide. After creating your plugin with

npx @capacitor/cli plugin:generate

the guide says “To compile the plugin, navigate into the plugin directory then run:”

npm run build

However when I do that, all I get is this error message:

test-plugin@0.0.1 build C:\Users\foobar\Desktop\testplugin\test-plugin
npm run clean && tsc && rollup -c rollup.config.js

test-plugin@0.0.1 clean C:\Users\foobar\Desktop\testplugin\test-plugin
rimraf ./dist

[!] Error: No valid exports main found for 'C:\Users\foobar\Desktop\testplugin\test
-plugin\node_modules\@rollup\plugin-node-resolve'
Error: No valid exports main found for 'C:\Users\foobar\Desktop\testplugin\test-plu
gin\node_modules\@rollup\plugin-node-resolve'
    at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)
    at applyExports (internal/modules/cjs/loader.js:502:14)
    at resolveExports (internal/modules/cjs/loader.js:551:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
    at Function.Module._load (internal/modules/cjs/loader.js:855:27)
    at Module.require (internal/modules/cjs/loader.js:1033:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\foobar\Desktop\testplugin\test-plugin\rollup.co
nfig.js:5:19)
    at Module._compile (internal/modules/cjs/loader.js:1144:30)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-plugin@0.0.1 build: `npm run clean && tsc && rollup -c rollup.conf
ig.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-plugin@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\foobar\AppData\Roaming\npm-cache\_logs\2021-03-21T15_59_32_71
8Z-debug.log

My Node and NPM versions are as follows:

C:\Users\foobar\Desktop\testplugin\test-plugin>node --version
v13.6.0
C:\Users\foobar\Desktop\testplugin\test-plugin>npm --version
6.13.4

To be honest, I am beginning to doubt this thing is production-ready. When even the most basic Getting started guides and wizards don’t work out-of-the-box, it doesn’t exactly instill confidence in the maturity of the framework…

Looks like it’s a node 13.x problem (and only on some versions, fails on 13.6, but works with 13.14)

Anyway, Capacitor 3 is at RC state, so I would suggest to follow the v3 guide if you plan to develop plugins that are ready for Capacitor 3