After notion install-ing ts-node and typescript – corresponding to the installation instructions which indicate to do a global install of both – ts-node cannot run:
$ which ts-node
/Users/ckrycho/.notion/bin/ts-node
$ ts-node --version
Notion error: Could not execute command.
See `notion help install` and `notion help pin` for info about making tools available.
Error details written to: notion-error-2019-04-12_08_41_39.811.log
$ cat ~/.notion/log/notion-error-2019-04-12_08_41_39.811.log
ts-node --version
Notion v0.2.2
Notion error: Could not execute command.
See `notion help install` and `notion help pin` for info about making tools available.
cause: Permission denied (os error 13)
I suspect the problem is that ts-node actually just isn't finding the TypeScript library, since it's likely relying on being able to use the Node resolution algorithm to find it – it looks to me like it's effectively treating it as a peer dependency, at first blush.
(I haven't dug into this yet, but wanted to note it so I don't forget it.)
I took a quick look, and the cause of the "Permission denied" error is that the CLI file isn't executable in the file system. Filed #351 to address that. Once that is fixed (I tried it manually by doing chmod +x), however, we still get a node error about not being able to find Typescript.
We don't currently have a story for interop of global packages, they are currently all siloed and not easily available to each other. Another wrinkle is that for this case, ts-node isn't trying to find the typescript binary, but rather is doing an import("typescript"), and it is the node resolution of that import that is failing. So if we want this to work, we'll need to come up with a way to make the package scripts available in a way that Node knows about, not just on the PATH.
Adding notes from Discord:
I found part of a workaround, not sure if it's a good approach or not though. The key is that Node lets you set paths into NODE_PATH environment variable, that will be searched for modules when resolving. The trouble is that our file structure necessarily doesn't line up with what node wants to find: We put packages at <package>/<version>/..., but when node is resolving, it's looking for <package>/...
I also see that, at least for ts-node, typescript is correctly declared as a peerDependency, which is where these situations should come up, if at all
So I think we _could_ do this:
Redo our package image path to be <package>/<version>/<package>
When installing a tool, take note of its peer dependencies
<package>/<version> to NODE_PATHThat would mean when a package does require("typescript"), it would search the typescript/3.4.3/ directory, see a sub-directory named typescript, and use that for the import, which is what we would want it to do.
FYI - #351 (missing the +x) was fixed in https://github.com/volta-cli/volta/pull/396.
I'm calling this resolved (per Rob's comment last May); but also linking to #652, which some of the follow-on discussion is relevant for.
Most helpful comment
FYI - #351 (missing the +x) was fixed in https://github.com/volta-cli/volta/pull/396.