angular-cli: In latest angular 4.1 / cli 1.1 getting Uncaught ReferenceError: require is not defined
I’m submitting a … (check one with “x”)
[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
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
Uncaught ReferenceError: require is not defined
(anonymous function)
(anonymous function)
webpackJsonp.25.module.exports
732
__webpack_require__
1658
__webpack_require__
webpackJsonpCallback
(anonymous function)
Looking at the stack won’t help much:
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(src) {
if (typeof execScript !== "undefined")
execScript(src);
else
eval.call(null, src);
}
//////////////////
// WEBPACK FOOTER
// ./~/script-loader/addScript.js
// module id = 25
// module chunks = 11
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
git clone https://github.com/born2net/studio-lite.git
cd studio-lite
npm install -g @angular/cli@latest
npm install
open browser to: http://localhost:4208/
versions:
@angular/cli: 1.0.1
node: 6.9.5
os: win32 x64
@angular/animations: 4.1.0
@angular/common: 4.1.0
@angular/compiler: 4.1.0
@angular/core: 4.1.0
@angular/forms: 4.1.0
@angular/http: 4.1.0
@angular/platform-browser: 4.1.0
@angular/platform-browser-dynamic: 4.1.0
@angular/router: 4.1.0
@angular/cli: 1.0.1
@angular/compiler-cli: 4.1.0
@angular/language-service: 4.1.0
@ngtools/webpack: 1.3.1
Regards,
Sean
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (4 by maintainers)
@born2net I tried installing your example, running
ng serve -o
, and I saw this error:Then I changed the CLI dependency from
"@angular/cli": "^1.0.1",
to"@angular/cli": "1.0.0",
, reinstalled everything, and I saw the same error on the browser.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
ng new repro-app
, and then add the minimum possible to see the error.