Open SimplGy opened 1 year ago
Noting that in finder, /Users/eric/.kenv/node_modules/@johnlindquist/kit/
appears to be an empty folder
@SimplGy the ~/.kenv/package.json should show "@johnlindquist/kit" pointing to ~/.kit
It should be using node from ~/.knode/bin/node regardless of what version of node you have installed elsewhere.
If you want to "reset" the Kit.app:
Getting a similar issue
[2023-02-07 16:25:08.618] [warn] ☠️ ERROR PROMPT SHOULD SHOW ☠️
[2023-02-07 16:25:08.619] [warn] Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@johnlindquist/kit' imported from /private/var/folders/14/sk4mzw5s1h9gz1dc2xmgbvc80000gq/T/kit/myfile.mjs
at new NodeError (node:internal/errors:387:5)
at packageResolve (node:internal/modules/esm/resolve:957:9)
at moduleResolve (node:internal/modules/esm/resolve:1006:20)
at defaultResolve (node:internal/modules/esm/resolve:1220:11)
at nextResolve (node:internal/modules/esm/loader:165:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
at ModuleWrap.
@le250055 Did anything happen before this error started occurring that you think may have caused it?
TL;DR: Confirmed both statements in my environment and "reset" the app, but still see the same error
the ~/.kenv/package.json should show "@johnlindquist/kit" pointing to ~/.kit
Confirmed, looks right:
➜ .kenv cat package.json
{
"type": "module",
"devDependencies": {
"@johnlindquist/kit": "file:../.kit",
"image-downloader": "^4.3.0",
"sharp": "^0.31.3"
}
}
~/.kit
is not an empty folder, so not sure why I'm seeing Cannot find package '/Users/eric/.kenv/node_modules/@johnlindquist/kit/
It should be using node from ~/.knode/bin/node regardless of what version of node you have installed elsewhere.
Ah, good to see how this works. Confirmed.
-rwxr-xr-x 1 eric staff 79M Sep 22 20:39 node
lrwxr-xr-x 1 eric staff 38B Feb 4 18:09 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxr-xr-x 1 eric staff 38B Feb 4 18:09 npx -> ../lib/node_modules/npm/bin/npx-cli.js
➜ bin ./node -v
v16.17.1
➜ bin ./npm -v
8.15.0
➜ bin npm -v
9.3.1
➜ bin node -v
v18.14.0
➜ ~ rm -rf ~/.kit
➜ ~ rm -rf ~/.knode
browse(url)
script@SimplGy If you manually link ~/.kit to ~/.kenv like so:
cd ~/.kenv && PATH=~/.knode/bin:$PATH npm i ~/.kit
Does that:
~/.kenv/package.json
looks like?npm install shows a progress bar for a few moments, then appears to fail in this way:
➜ $ cd ~/.kenv
➜ $ PATH=~/.knode/bin:$PATH npm i ~/.kit
npm ERR! code ENOTDIR
npm ERR! syscall rename
npm ERR! path /Users/eric/.kenv/node_modules/@johnlindquist/kit
npm ERR! dest /Users/eric/.kenv/node_modules/@johnlindquist/.kit-XKBdfT1i
npm ERR! errno -20
npm ERR! ENOTDIR: not a directory, rename '/Users/eric/.kenv/node_modules/@johnlindquist/kit' -> '/Users/eric/.kenv/node_modules/@johnlindquist/.kit-XKBdfT1i'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/eric/.npm/_logs/2023-02-11T20_14_15_190Z-debug-0.log
...looking...
My PATH is:
➜ $ echo $PATH
/Users/eric/.nvm/versions/node/v18.14.0/bin:/Users/eric/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/eric/bin
That thing is a sym link:
➜ $ lsa /Users/eric/.kenv/node_modules/@johnlindquist/
lrwxr-xr-x 1 eric staff 13B Feb 4 19:13 .kit-XKBdfT1i -> ../../../.kit
This succeeds (inside .kenv folder)
➜ .kenv rm -rf node_modules
➜ .kenv npm i
# ...
added 472 packages, and audited 473 packages in 16s
after doing that, now this also succeeds:
.kenv npm i ~/.kit
up to date, audited 473 packages in 1s
@SimplGy Now I'm really curious 😅
(fyi, that npm i command works on my machine 🙃)
Back in a working state! 🎉
I think it was rm -rf ~/.kenv/node_modules
that fixed it, although I also deleted package-lock.json
at some point too.
Wish I could tell you what the problem was, these environment issues must be a real challenge. Really appreciate the help and look forward to building some amazing automations with this tool.
@SimplGy Hrmmmmmmmmmmm 🤔
By any chance, did you ever use yarn
inside of ~/.kenv
?
No, not on purpose/manually.
I haven't used yarn in a long time and I'm sure of that because I can't remember what it's for. 😁
@SimplGy I really appreciate you taking the time to look into it!!! 🙏
Glad we at least have a fix for now.
The setup process literally does npm i ~/.kit
just like we did above.
I'm curious if installing sharp
or image-downloader
caused some strange npm side effect. I can't think of what else may have impacted it...
Hey @johnlindquist I have a similar issue. I updated to node 18.12.1. I installed canvas and d3-node and I have a weird behavior. My others scripts run in both launcher and cli. But the one which uses canvas works only in the cli. If I run it from the app I got:
[08:32:03.105] [warn] ☠️ ERROR PROMPT SHOULD SHOW ☠️ [08:32:02.970] [info] Found d3-node in /Users/victormartinezmejias/.kenv/package.json
$ cd ~/.kit
[08:27:27.980] [info]
at async file:///~/.kenv/scripts/generate-graph.js:5:16
at kenvImport (file:///~/.kit/api/npm.js:77:15)
the module (for instance, using npm rebuild
or npm install
).
[113. Please try re-compiling or re-installing
[108. This version of Node.js requires
was compiled against a different Node.js version using
[08:27:27.978] [warn] Error: Error: The module '~/.kenv/node_modules/canvas/build/Release/canvas.node'
Do they run different?
@vhmartinezm I'll get this sorted in this week's build.
It's a matter of the script running from the app's node vs the ~/.knode/bin/node.
I made the change to run on the app's node because Windows would show a spinner any time your launch ~/.knode/bin/node. I may end up adding a metadata like below to force the app to use knode:
// Node: ~/.kit/bin/node
Not sure yet, but it ll be fixed soon.
@johnlindquist thank you for your answer. I like the metadata definition. I'll be waiting
Hey @johnlindquist! Any news on this topic in the latest version (1.53.22)?
@vhmartinezm Should be sorted 👍
@vhmartinezm Testing with this:
Open testing-node-canvas in Script Kit
// Name: Testing node-canvas
import "@johnlindquist/kit"
let { createCanvas, loadImage } = await import("canvas")
let canvas = createCanvas(200, 200)
let ctx = canvas.getContext("2d")
// download script kit logo
let buffer = await download(
`https://d2eip9sf3oo6c2.cloudfront.net/playlists/square_covers/000/533/034/thumb/script-kit_2x.png`
)
let image = await loadImage(buffer)
ctx.rotate(0.1)
ctx.drawImage(image, 0, 0, 200, 200)
let filePath = tmpPath("canvas.png")
await writeFile(filePath, canvas.toBuffer())
// open with preview
await exec(`open ${filePath}`)
@johnlindquist worked perfect, thanks!
I was in a state where script kit could run the intro script, but nothing with an NPM dependency. So, I updated that stuff.
Now, it can't even run the intro script. So, I wonder if changing the default version of node/npm breaks things. I'm sorry I don't, but I have no idea how to get it into a correct state again.
Background
The commands I ran to update the node environment were something like:
I'm looking for a "re-run setup procedure" option maybe?
Current State Error Output
Run this very simple intro script:
Get this error: