path icon indicating copy to clipboard operation
path copied to clipboard

Does not work in phantomjs: process is undefined

Open jdpopkin opened this issue 9 years ago • 5 comments

This module implicitly depends on process, which isn't defined outside of Node. Prior to a2f87c3ae9b698f3f085c344714fbd4376905e22, this module had an extra var process = process || {}; in path.js that allowed the use of functions that don't meaningfully rely on process.

And since it sounds like people shouldn't be using this module in Node itself (#6), this problem might affect most legitimate users of this module.

See https://github.com/philc/vimium/commit/da57280c3e2ec80cf8e98c8634305e59b8f52f53 for an example of a legitimate use of this library that was broken by the removal of var process = process || {};.

jdpopkin avatar Jan 01 '16 19:01 jdpopkin

Got following error while generating pdf using Phantom-pdf package:

Checking if phantomjs is installed in provided path: phantomjs ReferenceError: Can't find variable: process

F:/Projects/Javandi/node_modules/path/path.js:25 F:/Projects/Javandi/node_modules/path/path.js:629

does not works with phantomjs??? could anybody help me how to fix this error???

gcmeen avatar Dec 15 '16 05:12 gcmeen

Workaround:

Before you require('path'), do:

window.process = {};

This will create a (dummy) variable process so the error goes away.

Download avatar Apr 04 '17 19:04 Download

This is also a problem for anyone using Angular 6 with this library.

Below is the line that I am seeing that fails in Angular 6. https://github.com/jinder/path/blob/master/path.js#L25

Below is a link to Angular saying that they remove the nodejs shims https://github.com/angular/angular-cli/issues/9827#issuecomment-369578814

lancewf avatar Sep 07 '18 23:09 lancewf

@lancewf we're you able to find a solution for this?

japo32 avatar Oct 05 '18 03:10 japo32

define process.env in vite.config.js file


export default defineConfig({
  plugins: [
    vue()
  ],
  define: {
    'process.env': {}
  }
})

gongzhxu avatar Apr 24 '23 02:04 gongzhxu