Normally in NPM you can install a package under an alias, like so:
npm i alias@npm:real-package-name
For reference, here's where the aliasing feature was announced: https://npm.community/t/release-npm-6-9-0/5911
b7b54f2d1 413 #3 530 Add support for package aliases. This allows packages to be installed under a different directory than the package name listed in package.json, and adds a new dependency type to allow this to be done for registry dependencies. (@zkat 50)
This allows you to import/require the package using its alias instead of its real name:
import foo from 'alias'
However, when I try to do this with the ESM-bundled version of Chai:
npm i --save-dev chai@npm:bundled-es-modules/chai
I get the error "aliases only work for registry deps" ... but I can't find any information about what that error actually means at all. Here's the full stack trace:
25 verbose stack Error: aliases only work for registry deps
25 verbose stack at fromAlias (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:270:11)
25 verbose stack at resolve (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:70:12)
25 verbose stack at npa (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:52:10)
25 verbose stack at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:406:31
25 verbose stack at Array.map (<anonymous>)
25 verbose stack at Arborist.[add] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:405:28)
25 verbose stack at Arborist.[applyUserRequests] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:390:23)
25 verbose stack at Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:207:37)
25 verbose stack at async Promise.all (index 1)
25 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:123:5)
Can anyone explain what this error means, and why I can't alias that package (or if I can, what I'm doing wrong)?