You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm posting an issue I had with the browserify-adventure "writing transforms" lesson and it's solution because it caused me a fair amount of headache.
The issue was that running a correct solution, even the reference solution, would fail.
$ browserify -t ./tr.js main.js
/usr/local/lib/node_modules/browserify-adventure/problems/using_transforms/wake.txt:1
Be that as it may, but for that light phantastic of his gnose's glow as it
^
ParseError: Unexpected token
The problem has nothing to do with your code but instead is because the wake.txt file is in a node_modules directory, and is discussed here: browserify/browserify#515. Essentially, by default you can't use a transform on a module that requires a file that lives in a node_modules directory, because by design browserify only transforms top-level modules, i.e. modules not in node_modules.
There are 2 solutions. You can either copy the wake.txt file to a directory outside of the node_modules directory, e.g. your current working directory, or you can specify the --global-transform (-g) option at the command prompt. In my opinion, it's probably better to just copy the file rather than use the global transform option, since using global transform is "dangerous" and not something you'd want to use in the future unless you really understand why you're using it.
I'm posting an issue I had with the browserify-adventure "writing transforms" lesson and it's solution because it caused me a fair amount of headache.
The issue was that running a correct solution, even the reference solution, would fail.
The problem has nothing to do with your code but instead is because the wake.txt file is in a node_modules directory, and is discussed here: browserify/browserify#515. Essentially, by default you can't use a transform on a module that
require
s a file that lives in a node_modules directory, because by design browserify only transforms top-level modules, i.e. modules not in node_modules.There are 2 solutions. You can either copy the wake.txt file to a directory outside of the node_modules directory, e.g. your current working directory, or you can specify the --global-transform (-g) option at the command prompt. In my opinion, it's probably better to just copy the file rather than use the global transform option, since using global transform is "dangerous" and not something you'd want to use in the future unless you really understand why you're using it.
Solution 1
In main.js
Solution 2
The issue is also addressed in the browserify-adventure issues, workshopper/browserify-adventure#20.
The text was updated successfully, but these errors were encountered: