Even though I have nodeLinker: node-modules
in my yarnrc.yml, it still doesn't create the node_modules folder. It still creates the .pnp.cjs and .pnp.loader.mjs files and the .yarn folder. According to the yarn workspaces docs, the node_modules folder is necessary to use workspaces.
When I try to run yarn start
in one of my individual package directories it says
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
. It says the same thing when I run yarn workspace package-b start
.
I'm using yarn v3.3.1, and node v19.2.0.
Here's my directory structure:
root
|- package.json
|- yarnrc.yaml
|- package-a
|- package.json
|- index.ts
|- package-b
|- package.json
|- index.ts
Here's my root package.json:
{
"name": "my-workspace",
"private": true,
"workspaces": [
"package-a",
"package-b"
]
}
package-a package.json:
{
"name": "package-a",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "microbundle-crl watch --no-compress --format modern,cjs",
...
},
"dependencies": {
"cross-env": "5.0.5"
}
}
package-b package.json:
{
"name": "package-a",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "react-scripts start",
...
},
"dependencies": {
"cross-env": "5.0.5",
"package-a": "1.0.0"
}
}
index.ts in package-a
export const MY_CONSTANT = 5;
index.ts in package-b
import * as PackageA from 'package-a';
console.log(PackageA);
My root yarnrc.yml:
nodeLinker: node-modules
The only way it works is if I yarn install; yarn start
in package-a, then yarn install; yarn start
in package-b. This creates the node_modules/ folder in both packages.
Expected: Running yarn install
and yarn workspace package-b start
would have successfully run package-b.