relative paths break?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, nodejs
- Domain
- tooling
Research direction
Start with the node-hook require hook and reproduce the failure from pages/test.js at line 19, using the pass-through preprocess function shown in the issue. Check how relative module resolution behaves when .js and .jsx extensions are hooked. Done means the relative require of ../lib/site/routes works with node-hook enabled, with and without an explicit .js extension.
Written by the indexing model from the issue text.
Description
I'm using the following test code, and am getting an interesting error.
var hook = require('node-hook');
function preprocess(source, filename) {
return source;
}
['js','jsx'].forEach(function(ext) { hook.hook('.' + ext, preprocess); });
Pretty straight-forward pass-through processing, the expectation is that this, of course, does nothing. Instead, it causes and error on the following line later in the same file (line 19 in the file) :
...
var RouteSet = require('../lib/site/routes');
...
Claiming:
module.js:328
throw err;
^
Error: Cannot find module '../lib/site/routes'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (J:\Junctions\Users\Mike\Documents\Git projects\projects\BezierInfo-2\pages\test.js:19:16)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
Without node-hook, this works just fine, it's just a relative file location, but with node-hook, things no longer work for relative requirements... I tried to change it to ../lib/sites/routes.js because maybe the automatic extension from node's site isn't kicking in, but that just gives the same error:
module.js:328
throw err;
^
Error: Cannot find module '../lib/site/routes.js'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (J:\Junctions\Users\Mike\Documents\Git projects\projects\BezierInfo-2\pages\test.js:19:16)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
- Dominant language
- JavaScript
- Stars
- 66
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bahmutov/node-hook
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
question
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
All issues in bahmutov/node-hook
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Edit: RTE News LogoOpencheck:failed logos:edit
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
iptv-org/database#36354 · 1 comment ·
Maintainers usually reply within 4 days
-
status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
midnightntwrk/midnight-wallet#791 ·
Maintainers usually reply within 1 day