Closed hannessolo closed 2 years ago
Thanks @hannessolo.
After investigation, the root cause is npm@7 and greater (the default with node-15 and greater), which uses npm exec
for npx init
now which appears to have different behaviour. With npm@6, it was working fine (default with node-14).
JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-1861
To test you might have to add @latest
so it picks up the latest version:
npx @adobe/create-aio-lib@latest FooLib adobe/FooLib
Thanks for the quick fix!
The example commands (both using npx and npm init) provided in the readme fail with an error.
Expected Behaviour
The repository is generated correctly running
code npx @adobe/create-aio-lib AioLibHeadless AEMSnSDevX/aio-lib-headless
Actual Behaviour
The command errors:
Details
The issue is here: https://github.com/adobe/create-aio-lib/blob/3465de513ac28c653609d802bb2c46447e50ea5a/src/commands/create.js#L104
This works if
create-aio-lib
is cloned as a local repository, and therefore has its ownnode_modules
directory containing the template. But it will not work if the template is installed as a peer ofcreate-aio-lib
, as it is in the context when running withnpx
.Potential Fixes
The code at https://github.com/adobe/create-aio-lib/blob/3465de513ac28c653609d802bb2c46447e50ea5a/src/commands/create.js#L104 should be changed to use the normal node module resolution process, looking for the module first in the current directory, then the parent etc. I'm not sure if this can be achieved using a built-in, or needs to be implemented from scratch.
As a temporary workaround, I ran
npm i @adobe/aio-lib-template
in the directory where the CLI tool expected the template to be. Could be added as a workaround to the readme, but long-term, this is not a great solution.Platform and Version
Mac 12.6,
@adobe/create-aio-lib@2.0.0
, node v16.14.2