Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require is not defined #395

Closed
zombodotcom opened this issue Sep 30, 2019 · 27 comments
Closed

require is not defined #395

zombodotcom opened this issue Sep 30, 2019 · 27 comments

Comments

@zombodotcom
Copy link

image

Uncaught ReferenceError: require is not defined
    at Object.url (index.js:36)
    at __webpack_require__ (bootstrap:726)
    at fn (bootstrap:100)
    at Object../node_modules/webpack-dev-server/client/utils/createSocketUrl.js (createSocketUrl.js:4)
@zombodotcom
Copy link
Author

zombodotcom commented Sep 30, 2019

Trying to fix Currency Cop to the new PoE League, devs arent keeping it UTD so I wanted to fix it.

https://github.com/currency-cop/currency-cop

running into webpack errors

already did nodeIntegration: true

@cheplv
Copy link

cheplv commented Oct 15, 2019

I'v found that this issue produced by postinstall switching between envs (electron/web). Need to switch to @angular-builders/custom-webpack - will add pull request next week

@Brandon9598
Copy link

Brandon9598 commented Oct 29, 2019

@zombodotcom I am having the same issue. Is there anything we can do to help @cheplv?

@cheplv
Copy link

cheplv commented Oct 29, 2019

Will try give commit today. It's quite simple ))

cheplv pushed a commit to cheplv/angular-electron that referenced this issue Oct 29, 2019
Add support for @angular-builders/custom-webpack
Setup environment target based on env params
Remove direct code changeing scripts postinstall/postinstall-web
@cheplv
Copy link

cheplv commented Oct 29, 2019

@zombodotcom @Brandon9598 @maximegris
Did a simple change with custom-webpack module.
This correctly builds for electron-renderer and web targets

@zombodotcom
Copy link
Author

thanks, i forgot I posted this. I got a lot further on my app. Thanks <3

maximegris added a commit that referenced this issue Nov 1, 2019
#395 - require is not defined
Awesome job @cheplv . Thanks a lot ! :)
@uzumakinaruto123
Copy link

I am still getting this! Pulled the latest master

external "url":1 Uncaught ReferenceError: require is not defined
    at Object.url (external "url":1)
    at __webpack_require__ (bootstrap:79)
    at Object../node_modules/webpack-dev-server/client/utils/createSocketUrl.js (createSocketUrl.js:4)
    at __webpack_require__ (bootstrap:79)
    at Object.<anonymous> (client:20)
    at Object../node_modules/webpack-dev-server/client/index.js?http://0.0.0.0:0/sockjs-node&sockPath=/sockjs-node (vendor.0e7e1a4672132539a6d0.js:375324)
    at __webpack_require__ (bootstrap:79)
    at Object.0 (main.ts:18)
    at __webpack_require__ (bootstrap:79)
    at checkDeferredModules (bootstrap:45)

main.ts: 18


platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));

@cheplv
Copy link

cheplv commented Nov 15, 2019

@maximegris Need to reopen ticket - I'v found another one thing that needs to be added.
electron security issue - today i has found this and fixed - but not commited
@uzumakinaruto123 just wait some days ((

@zombodotcom
Copy link
Author

sorry i was the one who closed it. i forgot what i did to fix it, didn't realize this was such a large issue.

@zombodotcom zombodotcom reopened this Nov 15, 2019
@cheplv
Copy link

cheplv commented Nov 15, 2019

yeah )) thx

@cheplv
Copy link

cheplv commented Nov 15, 2019

@maximegris PR that fixes security issue serving app on localhost
#408

@cheplv
Copy link

cheplv commented Nov 15, 2019

@uzumakinaruto123 can you check my PR and confirm that changes solve your issue?

@cheplv
Copy link

cheplv commented Nov 17, 2019

it seems that some days ago angular devs added support for custom webpack configuration:
angular/angular-cli@9f5c0f3

@uzumakinaruto123
Copy link

uzumakinaruto123 commented Nov 18, 2019

I pulled your PR and apparently everything was working. It works with a clean project.

It does not work in the project I am actually working on! I think I messed up some dependencies while merging another project into this one.

Steps to make an existing project compatible with this one would be helpful. Like, mentioning minimum dependencies and their versions.

I tried merging https://github.com/akveo/ngx-admin/blob/master/package.json in angular-electron.

@cheplv
Copy link

cheplv commented Nov 18, 2019

@uzumakinaruto123 you need to merge deps of project (package.json) step by step, seems that src and e2e folder can be just copy/paste with override.
Will try to do merge ngx-admin with angular-electron - will give you a feedback.

@uzumakinaruto123
Copy link

uzumakinaruto123 commented Nov 18, 2019

@cheplv Thanks a lot! I just tried it once and for the first attempt I decided to keep the latest versions of the two for common dependencies.

EDIT:
It works in Electron App. Throws error in the browser.

@ardai96
Copy link

ardai96 commented Nov 24, 2019

@cheplv I just clone master branch and saw this error on browser. Any news about this isuse?

@cheplv
Copy link

cheplv commented Nov 26, 2019

@ardai96 can you describe - how you get that error - step by step

@ardai96
Copy link

ardai96 commented Nov 26, 2019

@cheplv

  1. Clone repository
  2. npm i
  3. npm start
  4. Open google chrome on localhost:4200.
  5. Open dev tools and have error on console.

@cheplv
Copy link

cheplv commented Nov 26, 2019

@ardai96 "npm start" is intended to use only in electron environment i.e. opening direct localhost:4200 in browser will produce "require error" due build is for electron.
Use "npm run ng:serve:web" if you want to run in browser without electron.

@fbaldo31
Copy link

fbaldo31 commented Dec 1, 2019

Hi all,
I have currently the same issue (in electron environment) so with npm start

@cheplv
Copy link

cheplv commented Dec 1, 2019

@fbaldo31 how you face this error? if you used steps which mentioned in #395 (comment) - so this is incorrect use - you need only 3 first steps - opening in localhost etc is not intended - use internal electron app dev tools

@fbaldo31
Copy link

fbaldo31 commented Dec 1, 2019

npm start launch the app properly the navigator is useless.
But for unknown reason the error does not come anymore on my side

@cheplv
Copy link

cheplv commented Dec 1, 2019

@fbaldo31 ensure that you are latest master - due there was many changes in build/test process.

@fbaldo31
Copy link

fbaldo31 commented Dec 3, 2019

I have solved my issue, probably due by moving files :/

@cheplv
Copy link

cheplv commented Dec 3, 2019

@zombodotcom @maximegris think that we can close this issue

@maximegris
Copy link
Owner

Thanks @cheplv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants