Comments (7)
Awesome to see this finally being added to core.
from resolve-from.
I tried this out using require.resolve
with the paths
option but couldn't make it work given this structure:
unicorn
node_modules
foo.js
bar
cat.js
index.js
const path = require('path');
require.resolve('foo', {paths: [path.join(__dirname, 'unicorn', 'bar')]});
I'd expect it to use the regular module resolution and just traverse upwards. Works fine if I run it without the paths
option from cat.js
.
from resolve-from.
It should be
const path = require('path');
require.resolve('foo', {
paths: require.resolve.paths(path.join(__dirname, 'unicorn', 'bar'))
})
from resolve-from.
It should work anyway if it follows the usual module resolution which the documentation states it does. Anyway, it doesn't work using your example either.
from resolve-from.
require.resolve
doesn't work with custom paths (no idea why), but this module works fine
from resolve-from.
but it can't work with exports
access the esm entry
from resolve-from.
Now that NodeJS have paths option built in, then i suppose that there is no point in upgrading this pkg to ESM and we could just deprecate this package and say something like: just use native function, here is how...
from resolve-from.
Related Issues (9)
- Require resolves to the sibling node_modules if lookup failed in the given dir. HOT 2
- Browserify support HOT 1
- dependencies were not found HOT 1
- Test fails under node.js 12 due to expanded error message. HOT 1
- Support for extensions other than `.js` HOT 3
- Add Yarn PnP support? HOT 5
- Resolving require('module') for webpack HOT 1
- Use the real path for resolving dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resolve-from.