Navigator is not defined----bug

hi, after many tries I could not fix this bug
the backend starts failed
it seems the application can not find the platform

ReferenceError: navigator is not defined
    at /Users/zhouyin/Desktop/ZStudio/node_modules/@phosphor/domutils/lib/platform.js:18:23
    at Object.<anonymous> (/Users/zhouyin/Desktop/ZStudio/node_modules/@phosphor/domutils/lib/platform.js:46:3)
    at Module._compile (internal/modules/cjs/loader.js:967:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/zhouyin/Desktop/ZStudio/node_modules/@phosphor/domutils/lib/index.js:15:10)

navigator is a browser API.

If you require code in the backend that ends up executing browser scripts you will get errors.

thanks for your reply ,
actually i didnot use browser API in the backend
i got this error ,since when i restart the elctron app after i changed some codes
and then this error always exists and my app faild to open

@zhoujingfighting it is difficult to help without looking at the code, if would help if you can share it publicly (ex: github). What type of changes are you making? Are you importing frontend (browser) code in the backend (node), or backend code in the frontend perhaps?

If you import something new that imports something else that imports something else etc… It can lead to browser code being imported into the backend.

hi, after many tries again , I found something is totally wrong with the backend
sorry , I could not privide the whole codes of the extension, but I make a simplified version

  • firstly I found , the frontend could operate well, the simplified code runs as expected
  • secondly , after I add the backend module code eg:Fileservice, the error navigator is not defined showed again, but the other parts of our whole project runs well since I saw this error just behind the terminal output of the other modules
  • I have checked many times to ensure my imports are correct, even this simpilified module could not work with backend,
  • Maybe I am missing some important part , hope your guys can help me find the bug
    here is the repo theia-backend

@vince-fugnitto @paul-marechal
another code change i made before the app broke down was I used localstorage in the backend, I remembered got nothing ,then i realized that localStorage Service shouled be used in browser , but after that , when i refresh again , the app broke down , the error occured as I showed above

You are importing browser code in the backend runtime.

could you please tell me the exact wrong place, since I have not found the wrong place yet , tks :blush:

wow,tks,how silly is me :rofl:
so stupid mistake …
thank you very much for taking your time