-
Notifications
You must be signed in to change notification settings - Fork 12k
In latest angular 4.1 / cli 1.1 getting Uncaught ReferenceError: require is not defined #6106
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
Comments
@born2net I'm not sure if it's the same cause because I don't use the CLI but I had the exact same symptoms as you. I ran into this issue while following the tutorial on the Angular website for Universal with Webpack. In my Webpack config I had the target set to 'node', but if it's to be run in the browser then the target should be set to 'web'. When the target is set to 'node', webpack allows NodeJS to handle module resolution using require, when it's set to 'web' then Webpack will monkey patch all the require statements. |
ya I am on cli so I don't have much control. |
I am using angular-cli to build a project that uses electron and I am having a similar issue. I double-checked that I have @types/node installed as referenced by the issue #2099. |
Heya, can you provide a simple repro? https://github.com/born2net/studio-lite isn't a very minimal at all and it's very hard to figure out what's wrong in the middle of a full-blown application. Preferably a brand new project with the minimum number of changes needed to see the issue you are experiencing. |
hi, the app is kind of big however the error is thrown before anything even loads |
before the main module |
I'm sorry but I really need a simple repro to investigate. When you have time to put one together I can have a look. |
ok will do, |
@filipesilva Try this repo: https://github.com/madCoder24/sample-app If it isn't minimal enough please let me know and I can try to reduce it. |
@madCoder24 it looks like you're trying to do an electron project, but I have to say we don't really have official electron support. I ran your app with
This is true, in the browser there is no |
@filipesilva Okay. I appreciate you looking at it. |
@filipesilva ok I cut down the application to bare minimum so you can easily work oni it: Angular 2 Kitchen sink: http://ng2.javascriptninja.io Sean |
let me know if you have any questions @filipesilva |
@born2net when contributors/members ask for a simple repro, they normally mean to start a new project from scratch and trace your steps in reproducing the problem. By doing this, you isolate the problem from the rest of your application, which makes it easier for contributors to resolve. Often enough people actually realise the fault is on their side when they trace the steps to reproducing the problem. |
Yes I can understand that however I am pretty confident that in this case there is a bug as in 4.0 there were no issues and 4.1 the error bagan, same code base, regards |
Regardless, you still need to provide the most simplistic steps to reproduce the problem as possible. Which means starting a new project from scratch and reproducing the problem with that rather than a full blown application that has been stripped back a bit. |
@filipesilva will you be able to work with the existing project as its pure cli project and I removed everything as it just has a single component. The error is derived from the cli config and not the project itself. i.e., it's erroring on require because of libs that are included in packages.json which has require in them and not the project code. |
Sorry, I was looking at angular kitchen sink! |
ya no it's this one: https://github.com/born2net/cli-filipesilva |
@born2net I tried installing your example, running
Then I changed the CLI dependency from This tells me that the error is not related to the CLI itself, but rather something in your application. I noticed there's a service worker running, remember to disable it if you want to see up to date results. Also, next time when you wish to present a bug please do take the time to make a very simple repro to show it. https://github.com/born2net/cli-filipesilva has over 90 dependencies... it's very hard to try and discern if an error is due to your application or to the build system. A good way to make a simple repro is to make a brand new application via |
Thank you for the update, I will work on this some more and report my findings. |
You can try and check if in your angular-cli.json you added some script path not valid |
To reproduce Angular v.8+: generate Repository choosing Electron: changes in angular-cli.json etc. When it worked: |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
Up to ng 4.0.1 / cli 1.0 all was great
upg to 4.1 and 1.1 and now I am getting
Looking at the stack won't help much:
let me add that everything works, but getting this annoying message at runtime.
Expected behavior
no error
Minimal reproduction of the problem with instructions
You can see the issue with this project:
https://github.com/born2net/studio-lite
versions:
Regards,
Sean
The text was updated successfully, but these errors were encountered: