ng2-ui/tab

Error: (SystemJS) require is not defined(…)

Sicrum opened this issue · 8 comments

Hi there.

I am using VS2015 with Angular2.
Installed ng2-tab from npm and getting this:
"angular2-polyfills.js:349 Error: (SystemJS) require is not defined(…)"

Let me know if you need more details. Also, I can provide my PC via TeamViewer for debugging.

Thanks. Renat

P.S. stack:
angular2-polyfills.js:349 Error: (SystemJS) require is not defined
ReferenceError: require is not defined
at eval (http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js:11:14)
at eval (http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js:31:3)
at eval ()
Evaluating http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js
Error loading http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js as "ng2-tab" from http://localhost:50378/src/components/dashboard.component.js
at eval (http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js:11:14)
at eval (http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js:31:3)
at eval ()
Evaluating http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js
Error loading http://localhost:50378/lib/npmlibs/ng2-tab/dist/index.js as "ng2-tab" from http://localhost:50378/src/components/dashboard.component.js

Thanks for using this module, but this is out of scope question, I think.

A require statement is CommonJS module format, not SystemJS format

I also googled this,
http://stackoverflow.com/questions/34730010/angular2-5-minute-install-bug-require-is-not-defined

There is CommonJS speicified in my tsconfig. Do you think this is something related to Visual Studio?
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs", << ====
"noEmitOnError": false,
"noImplicitAny": false,
"outDir": "../wwwroot/src/",
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"compileOnSave": true,
"exclude": [
"node_modules"
]
}

it must be systemjs to run your app on browser. http://stackoverflow.com/a/34954984/454252

Sorry, I found angular.io uses commonjs https://angular.io/docs/ts/latest/quickstart.html. I think I am missing something. Does your app run without ng2-tab?

If not, plz post this question to stackoverflow, so that you will get your answers a lot faster than here.

yeah, it was working ok before adding ng2-tab

Did you use ng2-tab.umd.js?

In System.config->Packages I have replaced index.js with ng2-tab.umd.js and got another issue: core_1.Input is not a function . There is something wrong with decorators referencing in TS file generated by webpack.
Generated TS file itself is ok. I copied it into my project and tabs component works ok