Closed ailisp closed 2 years ago
When not using npm link, node_modules have near-workspaces-ava and its dependencies installed. Such as above ts-node
, and therefore no error happens.
When using npm link, node_modules look like this (note on the nested node_modules dir structure):
Now below code cannot find dependencies, so we need to fix this function:
function resolveModules(modules) {
return arrify(modules).map(name => {
const modulePath = resolveCwd.silent(name);
if (modulePath === undefined) {
throw new Error(`Could not resolve required module ’${name}’`);
}
Indeed the bug is resolveCwd doesn't handle npm link
module well. And resolveCwd is used in ava
, not part of our codebase. So the fix should be in ava
(not near-workspaces-ava), and use the fixed version of ava in near-workspaces-ava
We had been using yarn which handled all of the linking out of the box as it was a yarn workspace.
@willemneal Have also tried yarn link, aboveresolveCwd
bug also prevented me to link of workspaces-ava. The bug has been tracked in https://github.com/avajs/ava/pull/2971 and https://github.com/avajs/ava/issues/2985
I'm saying that yarn link
isn't needed. Since it was a workspace yarn
or yarn install
handles it.
Currently, near-workspaces-init generates a near-workspaces directory, which has a package.json, and has
near-workspaces-ava 1.0.0
as dependency.Because some new commits haven't released, I want to use main branch of near-workspaces-ava. So I run
npm link
inpackages/ava
. And runnpm link near-workspaces-ava
in generated near-workspaces. However, runnpm run test
now fails at: