ws-scrcpy icon indicating copy to clipboard operation
ws-scrcpy copied to clipboard

Uncaught (in promise) ReferenceError: process is not defined

Open tiennguyen12g opened this issue 3 years ago • 12 comments

Hello everyone, i get this error when run index.html and access to (http://localhost:8000) in dist folder. I check "process" in the path ws-scrcp/scr/server/index.ts. Where is "process" from ? Can you help me, thank all you?

tiennguyen12g avatar Mar 29 '23 08:03 tiennguyen12g

Hi. Can you provide the exact steps, what you do after cloning?

drauggres avatar Mar 29 '23 16:03 drauggres

Hi. Can you provide the exact steps, what you do after cloning?

  • After clone, i run "npm i" and "npm start" , it auto start a server localhost:8000.
  • The command has created a folder called "dist". I go to the " dist" folder and open file html inside it.
  • I check console it shows the error above.

tiennguyen12g avatar Mar 29 '23 17:03 tiennguyen12g

After npm start just open http://localhost:8000/ in your browser. There is no need to open files any files in "dist".

drauggres avatar Mar 29 '23 18:03 drauggres

After npm start just open http://localhost:8000/ in your browser. There is no need to open files any files in "dist". image

Let see the picture, i running project by npm start, and access to localhost:8000 or 127.0.0.1:8000, it returns an error

tiennguyen12g avatar Mar 30 '23 08:03 tiennguyen12g

This is weird.

You can build and development version:

  1. npm run clean
  2. npm run dist:dev
  3. cd dist
  4. npm start

Source maps are enabled in this version, so it will be possible to see the place where the exception occurs.

drauggres avatar Mar 30 '23 15:03 drauggres

But I am sure /src/server/index.ts has nothing to do with this. This file is not included in the client bundle.

drauggres avatar Mar 30 '23 15:03 drauggres

But I am sure /src/server/index.ts has nothing to do with this. This file is not included in the client bundle.

image

Frist test: I delete all older ws-scrcpy folder and clone new project. I follow your steps but still get error.

Second test: I continue delete project and clone second new project. I run "npm i" and add package "npm i path". Access to dist "cd dist" , run "npm start" and get the same error at the frist test

tiennguyen12g avatar Mar 30 '23 16:03 tiennguyen12g

path and process are part of the node.js API. There is no need for you to install them. When webpack builds the client it should use specific versions instead: https://github.com/NetrisTV/ws-scrcpy/blob/ee87ba65258057e76af7c1e67e7e6633361a62cb/webpack/ws-scrcpy.common.ts#L105-L110

drauggres avatar Mar 30 '23 17:03 drauggres

But I am sure /src/server/index.ts has nothing to do with this. This file is not included in the client bundle.

Can you show me the result when we access the localhost:8000?

tiennguyen12g avatar Mar 30 '23 18:03 tiennguyen12g

path and process are part of the node.js API. There is no need for you to install them. When webpack builds the client it should use specific versions instead:

https://github.com/NetrisTV/ws-scrcpy/blob/ee87ba65258057e76af7c1e67e7e6633361a62cb/webpack/ws-scrcpy.common.ts#L105-L110

I think in Readme it is lack of guide. Because after we run server , we have to run command "adb forward tcp:8886 tcp:8886" and connect to the url with several param look like: http://127.0.0.1:8000/#!action=stream&udid=R9HT10HL56R&player=broadway&ws=ws%3A%2F%2F127.0.0.1%3A8887%2F .

tiennguyen12g avatar Mar 31 '23 08:03 tiennguyen12g

Can you show me the result when we access the localhost:8000?

262

drauggres avatar Mar 31 '23 14:03 drauggres

I think in Readme it is lack of guide. Because after we run server , we have to run command "adb forward tcp:8886 tcp:8886" and connect to the url with several param look like: http://127.0.0.1:8000/#!action=stream&udid=R9HT10HL56R&player=broadway&ws=ws%3A%2F%2F127.0.0.1%3A8887%2F .

This is not necessary. Something is wrong with your build. I am sure it has something to do with webpack, but not sure what exactly.

drauggres avatar Mar 31 '23 14:03 drauggres