ERR_PACKAGE_MAP_EXTERNAL_FILE


一个模块尝试使用 地图包 解析一个裸引用,但导入的文件不在映射中定义的任何包内。

🌐 A module attempted to resolve a bare specifier using the package map, but the importing file is not located within any package defined in the map.

$ node --experimental-package-map=./package-map.json /tmp/script.js
Error [ERR_PACKAGE_MAP_EXTERNAL_FILE]: Cannot resolve "dep-a" from "/tmp/script.js": file is not within any package defined in /path/to/package-map.json 

要修复这个错误,确保导入的文件位于包映射中列出的某个包目录内,或者添加一个新的包条目,其 url 包含导入的文件。

🌐 To fix this error, ensure the importing file is inside one of the package directories listed in the package map, or add a new package entry whose url covers the importing file.