I'm planning of building my own package manager and registry, but I need to support file:
dependencies. The reason why I want to do this is the lot of trouble I have using NPM, Bun, or whatever, and the forced use of React in the ecosystem leads to version conflicting to ever changing React's major version (I want to sort of create a React-Emotion-TypeScript-TypeDoc integrated ecosystem that targets HTML5 and Node.js).
I'm just playing with node_modules
, but am unable to symlink a local dependency there. Why can Node.js do it through symlink too though?
Reproducing it. I have created these files manually, and symlinked the y
directory using Windows Create shortcut* action.
x/index.ts
// Could not resolve "y" module (TypeScript IDE error)
import { property } from "y";
x/tsconfig.json
{
"compilerOptions": {
"target": "ES2024",
"moduleResolution": "node",
"preserveSymlinks": true
}
}
x/node_modules/y = symlink to a y directory
x/node_modules/y/package.json
{
"name": "y",
"version": "0.1.0",
"main": "index.ts"
}
x/node_modules/y/index.ts
export const property: number = 10;
x/node_modules/y/tsconfig.json
{
"compilerOptions": {
"target": "ES2024"
}
}
Why is y
not found when importing it from x
?
I'm planning of building my own package manager and registry, but I need to support file:
dependencies. The reason why I want to do this is the lot of trouble I have using NPM, Bun, or whatever, and the forced use of React in the ecosystem leads to version conflicting to ever changing React's major version (I want to sort of create a React-Emotion-TypeScript-TypeDoc integrated ecosystem that targets HTML5 and Node.js).
I'm just playing with node_modules
, but am unable to symlink a local dependency there. Why can Node.js do it through symlink too though?
Reproducing it. I have created these files manually, and symlinked the y
directory using Windows Create shortcut* action.
x/index.ts
// Could not resolve "y" module (TypeScript IDE error)
import { property } from "y";
x/tsconfig.json
{
"compilerOptions": {
"target": "ES2024",
"moduleResolution": "node",
"preserveSymlinks": true
}
}
x/node_modules/y = symlink to a y directory
x/node_modules/y/package.json
{
"name": "y",
"version": "0.1.0",
"main": "index.ts"
}
x/node_modules/y/index.ts
export const property: number = 10;
x/node_modules/y/tsconfig.json
{
"compilerOptions": {
"target": "ES2024"
}
}
Why is y
not found when importing it from x
?
The problem is that the Windows Explorer's Create shortcut action that I was using creates a file symbolic link, not a directory symbolic link.
I had to use the command prompt to create the symlink:
mklink /d "x/node_modules/y" "C:\Users\hydro\Repository Groups\Jet\y"
Then the y
module was finally found by TypeScript.