The TypeScript Track has been updated to Yarn 4 with PnP enabled. In short this is a method to deduplicate content on your harddisk/ssd/storage instead of the singularity that is called node_modules. In other words: it saves time and space, perhaps even spacetime?
However, because PnP installed packages are no longer available in the exercise directory, and tools (such as typescript / tsc) and editors (such as vscode) rely on the packages to be available locally, you must take a few new steps.
We now use corepack instead of bundling a version of yarn locally. Run corepack enable yarn on Node LTS or newer to receive a “last known good” version of of yarn. Before you do that you want to delete yarn installed via other methods such as npm install -g yarn.
We rely on the @yarnpkg/sdks to provide the resolver to read packages from the PnP cache. This means that you need to run the SDK hook-up once per assignment (and potentially restart your editor) for PnP to work.
Example commands for vscode
# Download an exercise
exercism download [...]
cd [...]
# This replaces yarn install
corepack enable yarn
corepack yarn install
corepack yarn dlx @yarnpkg/sdks vscode
# Open the editor
code .
If there are questions or issues, feel free to respond here. The TypeScript Test Runner has also been updated and should be able to handle both the older Yarn 3 and the newly updated Yarn 4 solutions.
I can’t run tests locally for typescript track exercises. Tried first in emacs on debian and later with webstorm on osx with arm, both are not working. I used corepack yarn install and corepack yarn dlx @yarnpkg/sdks base, before trying corepack yarn test
this is what I’m getting
corepack yarn test
node:internal/modules/run_main:115
triggerUncaughtException(
^
Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed.
Source path: /Users/redjocker/Exercism/typescript/two-fer/.meta/test-runner.mjs
Not found: /Users/redjocker/Exercism/typescript/two-fer/.meta/test-runner.mjs
at makeError (/Users/redjocker/Exercism/typescript/two-fer/.pnp.cjs:14434:34)
at resolveUnqualified (/Users/redjocker/Exercism/typescript/two-fer/.pnp.cjs:16176:13)
at resolveRequest (/Users/redjocker/Exercism/typescript/two-fer/.pnp.cjs:16216:14)
at Object.resolveRequest (/Users/redjocker/Exercism/typescript/two-fer/.pnp.cjs:16272:26)
at resolve$1 (file:///Users/redjocker/Exercism/typescript/two-fer/.pnp.loader.mjs:2045:21)
at nextResolve (node:internal/modules/esm/hooks:791:28)
at Hooks.resolve (node:internal/modules/esm/hooks:238:30)
at MessagePort.handleMessage (node:internal/modules/esm/worker:255:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Node.js v22.2.0
It seems that test-runner.mjs is missing inside the .meta directory. I don’t know why that happens, but it is possible that I misconfigured something. For now you can solve it by manually copying the following and save it as test-runner.mjs inside .meta. Sorry about this!
cc @ErikSchierboom / @iHiD is this a thing where it (now) only downloads files from .meta if they are inside the files array? Or is this a thing that is only broken for existing solutions? Then why did it update package.json?
The reason the file needs to be inside the .meta directory is because the script in package.json in the root refers to .meta/test-runner.mjs.
It is supposed to read config.json from the .meta directory, so do not change that to tsconfig.json or ../tsconfig.json.
If you do not see config.json inside the .meta directory, please let me know because then I know what to solve.