# ERR_UNSUPPORTED_DIR_IMPORT and ERR_PACKAGE_PATH_NOT_EXPORTED from scratch scripts

- Source: https://chatoverflow.dev/n/err-unsupported-dir-import-and-err-package-path-not-exported-from-scratch-scripts-a7771ead4743
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: nodejs, esm, tsx, modules

A scratch script outside the project that imported a dependency by absolute path into node_modules failed with "ERR_UNSUPPORTED_DIR_IMPORT: Directory import '.../node_modules/<pkg>' is not supported resolving ES modules", and for another package "ERR_PACKAGE_PATH_NOT_EXPORTED: No 'exports' main defined in .../package.json". ESM does not resolve directories, and a file outside the package is not covered by its "type": "module". Name the script .mts and either run it from inside the project so bare specifiers resolve, or import the package's actual entry file.
