Industrial
Industrial10mo ago

Error running program that uses `fp-ts` from npm (`Is a directory (os error 21)`)

https://github.com/Industrial/test-fp-ls/blob/main/mod.ts When I run deno run -A mod.ts I get:
error: Unable to load /home/tom/Code/code9/node/test-fp-ls/node_modules/.deno/fp-ts@2.16.1/node_modules/fp-ts/Option imported from file:///home/tom/Code/code9/node/test-fp-ls/mod.ts

Caused by:
Is a directory (os error 21)
error: Unable to load /home/tom/Code/code9/node/test-fp-ls/node_modules/.deno/fp-ts@2.16.1/node_modules/fp-ts/Option imported from file:///home/tom/Code/code9/node/test-fp-ls/mod.ts

Caused by:
Is a directory (os error 21)
Is my import_map.json wrong? https://github.com/Industrial/test-fp-ls/blob/main/import_map.json
GitHub
test-fp-ls/mod.ts at main · Industrial/test-fp-ls
Contribute to Industrial/test-fp-ls development by creating an account on GitHub.
GitHub
test-fp-ls/import_map.json at main · Industrial/test-fp-ls
Contribute to Industrial/test-fp-ls development by creating an account on GitHub.
2 Replies
Industrial
Industrial10mo ago
It works with esm.sh I would rather use npm: going forward, seeing as it works on deno deploy now.
Deno AI Helper
Deno AI Helper10mo ago
Based on the documentation, the error message you're seeing typically indicates that Deno is trying to import a directory instead of a file. This could be due to how the fp-ts package is structured or how it's being referenced in your import_map.json. In your import_map.json, you have:
{
"imports": {
"fp-ts": "https://cdn.skypack.dev/fp-ts@2.16.1"
}
}
{
"imports": {
"fp-ts": "https://cdn.skypack.dev/fp-ts@2.16.1"
}
}
This maps the fp-ts import to the URL https://cdn.skypack.dev/fp-ts@2.16.1, which is a directory. Deno expects to import a specific file, not a directory. You might need to specify the exact file in the fp-ts package that you want to import. For example, if you wanted to import the Option module from fp-ts, your import map might look like this:
{
"imports": {
"fp-ts/Option": "https://cdn.skypack.dev/fp-ts@2.16.1/Option"
}
}
{
"imports": {
"fp-ts/Option": "https://cdn.skypack.dev/fp-ts@2.16.1/Option"
}
}
Then in your mod.ts file, you would import the Option module like this:
import { Option } from "fp-ts/Option";
import { Option } from "fp-ts/Option";
Please note that the exact URL and import statement might differ based on the structure of the fp-ts package. You'll need to adjust them to match the actual structure of the package. If you continue to experience issues, it might be helpful to check if fp-ts has specific instructions for usage with Deno, or consider reaching out to the fp-ts maintainers for