browserify-adventure icon indicating copy to clipboard operation
browserify-adventure copied to clipboard

#8 Write transforms : Absolute paths?

Open mdda opened this issue 9 years ago • 6 comments

I successfully got the #8 solution going, both with the 'direct' through way, and the 'combining' way. However, there seems to be a problem if the 'main.js' file has an absolute include vs a relative include :

// This fails
//var txt = require("/usr/lib/node_modules/browserify-adventure/problems/writing_transforms/wake.txt");
// This works (assuming the wake.txt is copied from the path above to the local directory
var txt = require("./wake.txt");
console.log(txt);

The verification stage works fine, though I see from your solution source that there's a relative file require there too. Am I crazy, or does something different happen in the case of absolute paths?

mdda avatar Jul 24 '14 09:07 mdda

@mdda where is your entry script loaded? Absolute paths shouldn't change anything but if you're using a normal (not global) browserify transform, the transform will only be applied to files whose closest package.json file is the same as the entry script's. Try using an absolute path for your copy of wake.txt and if it works, that's the problem :)

hughsk avatar Jul 26 '14 16:07 hughsk

I get this same error, I'm on Windows (7 x64) and I came here looking for why it wasn't working. Copied the text file to local folder and indeed, './wake.txt' works but the absolute path doesn't.

I would have thought it was Windows paths having backslashes... the absolute path (doesn't work) looks like this:

var txt = require('c:\\Arquivos de Programas Portable\\Nodist\\bin\\node_modules\\browserify-adventure\\problems\\writing_transforms\\wake.txt');

But even if I replace \\s with /s (both are valid for Windows), still doesn't work.

This path can be read just fine from the command-line, but when running the script I get a ParseError because the text file was not passed through my ./tr.js.

Anyway, this seems to be a bug in browserify itself... I should go and complain about this to them.

CamiloMM avatar Aug 08 '14 05:08 CamiloMM

@CamiloMM did you manage to fix the issue? I'm experiencing same problem with browserify and windows

garygreen avatar Jun 10 '15 10:06 garygreen

@garygreen Funny thing, I forgot about this issue but am currently using browserify on Windows so this all may have been a bug with browserify-adventure.

CamiloMM avatar Jun 10 '15 12:06 CamiloMM

@CamiloMM From what I dimly remember, this wasn't really a browserify issue - it arose because of the way browserify-adventure installs (and refers to itself).

mdda avatar Jun 10 '15 16:06 mdda

you need to use the -g flag instead of the -t flag.

forivall avatar Jan 25 '16 20:01 forivall