question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Won’t work in browser because of process.cwd()?

See original GitHub issue

Admittedly 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:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
stucoxcommented, Mar 22, 2021

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!

1reaction
avincentmecommented, Jan 26, 2021

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

    plugins: [
        new webpack.ProvidePlugin({
            process: 'process/browser',
        })
    ],
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found