path-browserify icon indicating copy to clipboard operation
path-browserify copied to clipboard

Error in browser: `process` is not defined

Open tanishqkancharla opened this issue 3 years ago • 5 comments

When calling `path.resolve("tmp", ".."), this branch is triggered, causing an error in the browser (line 124 in index.js):

if (cwd === undefined)
  cwd = process.cwd();
path = cwd;
Uncaught ReferenceError: process is not defined

I think this error should be caught.

tanishqkancharla avatar Oct 28 '22 00:10 tanishqkancharla

+1

kolserdav avatar Jan 19 '23 09:01 kolserdav

The problem was solved when I used join instead of resolve.

kolserdav avatar Jan 19 '23 10:01 kolserdav

1

UniqueCrownClown avatar Apr 25 '23 07:04 UniqueCrownClown

安装process

yarn add process -S

vite.config.ts中配置注入process

安装@rollup/plugin-inject

yarn add @rollup/plugin-inject -D

plugins里面加入

import inject from '@rollup/plugin-inject'
inject({
  process: 'process/browser'
})

mmacchao avatar Jun 21 '23 03:06 mmacchao

我的那个 is

When calling `path.resolve("tmp", ".."), this branch is triggered, causing an error in the browser (line 124 in index.js):

if (cwd === undefined)
  cwd = process.cwd();
path = cwd;
Uncaught ReferenceError: process is not defined

I think this error should be caught.

我的那个issue 已经解决了 , 可以去看看

When calling `path.resolve("tmp", ".."), this branch is triggered, causing an error in the browser (line 124 in index.js):

if (cwd === undefined)
  cwd = process.cwd();
path = cwd;
Uncaught ReferenceError: process is not defined

I think this error should be caught.

我的那个issue 已经解决了,可以去看看

链接 https://github.com/browserify/path-browserify/issues/34

LuoRiWuSheng avatar Aug 30 '23 09:08 LuoRiWuSheng