Won’t work in browser because of process.cwd()?
See original GitHub issueAdmittedly I’m not using this through Browserify so not sure if that would make a difference, but this lib calls process.cwd()
which isn’t available in browsers (process
isn’t at all).
I wonder if it could be adapted to not use this — or at least use a default / accept a config option (empty string?) when process.cwd()
isn’t available — and hence be more portable.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Express-js can't GET my static files, why? - Stack Overflow
First things first: If you base the paths of your files and directories on the cwd (current working directory), things should work as...
Read more >Node.js process.cwd() Method - GeeksforGeeks
Return Value: This method returns a string specifying the current working directory of the node.js process. Below examples illustrate the use of ...
Read more >next js it looks like you're trying to use typescript but do not ...
process.cwd(). This returns the current working directory. Not reliable at all, as it's entirely dependent on what directory the process was launched from:....
Read more >Options - Babel.js
cwd. Type: string. Default: process.cwd(). The working directory that all paths in the programmatic options will be resolved relative to.
Read more >concurrently - npm
cwd : the working directory to be used by all commands. Can be overriden per command. Default: process.cwd() . defaultInputTarget : the default ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Given the above, I think that’s all fair enough and this issue is just taking up space remaining open 😁
FWIW I’d love to see the JS community moving more towards portable JS where possible, rather than relying on users having specific tools in their build chain, but it’s not remotely reasonable to demand that from a package which literally has the name of a bundler in its name!
You NEED to use path-browserify with a bundler like webpack or browserify.
With webpack version 5 onwards, webpack does not provide Node polyfills. Therefore you need to add a ProvidePlugin for process. ProvidePlugin essentially requires / imports a specific module for every js file that is resolved from your webpack entry.
Install process polyfill:
npm i process
Add the plugin to your webpack config