Closed dannyhw closed 2 years ago
should be fixed with https://github.com/nandorojo/solito/commit/d39d3b3608cabfa2a31a02b208c21f1e99e8ccf1
thanks for finding that!
No worries thanks for the quick response! Trying it now :)
@nandorojo getting a different error 😅
[solito] Failed to download example
Error: Cannot find module '/Users/danny/.npm/_npx/21214/lib/node_modules/create-solito-app/dist/package.json'
at webpackContextResolve (/Users/danny/.npm/_npx/21214/lib/node_modules/create-solito-app/dist/index.js:34:22233)
at webpackContext (/Users/danny/.npm/_npx/21214/lib/node_modules/create-solito-app/dist/index.js:34:22142)
at run (/Users/danny/.npm/_npx/21214/lib/node_modules/create-solito-app/dist/index.js:34:334281)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
code: 'MODULE_NOT_FOUND'
}
ah yeah I see the issue.
I'm not a node CLI developer often, so I forget that running the CLI from npx
isn't the same as on my computer lol.
I think I am pushing a fix now
FWIW, even though it errors, it actually is working. it's just failing to edit your package.json
with the proper name.
I'm not sure how to solve this. I'm using process.cwd()
to get the current place where the user is located, but that doesn't seem to be working.
ah I see so this require is throwing the exception?
const pkg = require(path.resolve(
process.cwd(),
resolvedProjectPath,
'package.json'
))
or the write after that
I could try some stuff locally if that's helpful
yeah that's the line. I'm playing with it now too. it seems to keep reading from .npx
instead of cwd. i'm going to try printing some stuff out to see what's up
maybe path.resolve is unnecessary there since it's already resolved? hm
well I think even if it is usually resolve is pretty smart and can remove extra things. Seems possible that npx might change the way process.cwd works though. There is probably a good example of this I can check in the storybook repo.
I'm going a bit crazy here. Shouldn't these log the same things, but one of them just has package.json
appended to it? Because they're logging totally different things. resolvedPackagePath
is correct, and somehow pkgPath
is giving me something in the wrong directory
Ah ok well I guess path.resolve tries to be clever since it wants to resolve a absolute path, you can use join to just put them together.
if the project path is already resolved its probably safe to just do path.join
right...I tried join
as well, weirdly that gives me the same error.
something feels so off. this code:
console.log('[solito] resolved path :', resolvedProjectPath)
const pkgPath = resolvedProjectPath + '/package.json'
console.log('[solito] package.json path:', pkgPath)
Results in this error:
[solito] resolved path : /path-to/create-solito-app/create-test-app
[solito] package.json path: /path-to/create-solito-app/dist/package.json
I replaced my actual paths with path-to
. How can this make any sense?
If I do this:
const pkgPath = `${resolvedProjectPath}/package.json`
It gives the wrong path. But if I take out /package.json
at the end, it gives the right one. It's as if the variable is getting hoisted early and cached or something.
Yeah that's gotta be it. When I use ts-node
it seems to work.
wow this is really weird, is there a chance it could be related to the spawning of a child process?
not really encountered this kind of thing before, no idea why it would just randomly change like that 😅
if you emit js from tsc and run that instead of using ts-node does it work?
I'll try that too. Have to go to dinner so I'm going to publish this without the editing of package.json for now so it doesn't have any substantial errors. Who knew CLI and FS was so complicated lol
Okay so it works for me now.
The only weird thing left is, when I deploy to Vercel, it doesn't work, but building locally does work. 🧐
fixed
Hey I love this, great work!
As mentioned on twitter I got an error running create-solito-app. Setting up with vercel got me a 404 though that could easily be a me problem since I've not used it before.
running
let me know if you need any more details.