Does not work in phantomjs: process is undefined
jdpopkin opened this issue · 5 comments
This module implicitly depends on process
, which isn't defined outside of Node. Prior to a2f87c3, 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 philc/vimium@da57280 for an example of a legitimate use of this library that was broken by the removal of var process = process || {};
.
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???
Workaround:
Before you require('path')
, do:
window.process = {};
This will create a (dummy) variable process
so the error goes away.
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
angular/angular-cli#9827 (comment)
define process.env in vite.config.js file
export default defineConfig({
plugins: [
vue()
],
define: {
'process.env': {}
}
})