Closed bacongobbler closed 2 months ago
I am not able to reproduce this locally. The template does specify a devDependency
on yargs
https://github.com/fermyon/spin-js-sdk/blob/99a38550a608c768f4d0bdb413acad102bb35fb0/templates/http-ts/content/package.json#L20
But I think you are correct in suggesting that it needs to be a dependency and not a devDependency. I think we can remove yargs
and componentize-js
from the dev dependency list on the template once those 2 are added as prod dependencies to the SDK package.
It works if you use the ts template, but it doesn't work if you try to install this package in a standalone app (choose your own adventure style 😄).
Here is how I was able to reproduce this locally:
><> mkdir myapp
><> cd myapp
><> npm init
><> npm install @fermyon/spin-sdk
><> npx j2w
node:internal/modules/esm/resolve:854
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@bytecodealliance/componentize-js' imported from /home/bacongobbler/code/github.com/bacongobbler/myapp/node_modules/@fermyon/spin-sdk/bin/j2w.mjs
at packageResolve (node:internal/modules/esm/resolve:854:9)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1157:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v20.12.2
Fix for ^^:
><> npm install -D @bytecodealliance/componentize-js
><> npm install -D yargs
Ah! We should add both those packages as prod dependencies on the SDK package. That should fix it.
This works on the latest release. Closing.
With
@fermyon/spin-sdk@2.0.0-alpha.0
, if I runnpx j2w
, I see the following:This is resolved if I run
npm install -D yargs
.I'm wondering if
yargs
should be added as a dependency of this project rather than adevDependency
. What do you think?https://github.com/fermyon/spin-js-sdk/blob/feat/sdk-v2/package.json#L19