browserify / browserify/resolve
Unable to resolve a package by its own name
- Dominant language
- JavaScript
- Stars
- 796
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
This is a reminder that [package self-referencing](https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name) is not supported at this time.
**package.json**
```json
{
"name": "my-package",
"main": "./index.js",
"dependencies": {
"resolve": "*"
},
"exports": {
".": "./index.js"
}
}
```
**index.js**
```js
const resolve = require('resolve/sync');
// prints full path of index.js
console.log(`require.resolve: ${require.resolve('my-package')}`);
// throws MODULE_NOT_FOUND
console.log(`resolve: ${resolve('my-package')}`);
```
---
**[DEMO LINK](https://stackblitz.com/edit/node-ofbthh?file=package.json,index.js)**
---
I imagine this must be a known limitation, since other features linked to module resolution in Node like [package imports](https://nodejs.org/api/packages.html#imports) are not supported either. I'm reporting this here anyway because I could not find a reference to this in the documentation or in any of the other issues.
Contributor guide
Assessment
This issue has not been assessed yet.