Npm module in Angular 2 project


#1

I cannot seem to use even simple npm packages in my project.

for example the simple uploader at:

Error i keep getting:

Uncaught ReferenceError: System is not defined


#2

Do you mean all NPM packages or just this one?

Try to install another one
npm install --save moment

Then add
import * as moment from 'moment';

and use like
console.log(moment().daysInMonth());

Does it work?


#3

Everyone I tried … no in the tutorial.

Seems to be a SystemJs error message.
But the recommened setup uses “commonjs”


#4

What is your Meteor version?


#5

I have set it up with METEOR@1.3.4.1

Afraid to update – using Windows 10.


#6

What does your tsconfig.json look like?


#7

{
“compilerOptions”: {
“experimentalDecorators”: true,
“module”: “commonjs”,
“target”: “es5”,
“isolatedModules”: false,
“moduleResolution”: “node”,
“emitDecoratorMetadata”: true,
“removeComments”: false,
“noImplicitAny”: false,
“sourceMap”: true
},
“filesGlob”: [
“client//*.ts",
"server/
/.ts",
"typings/**/
.d.ts”
],
“exclude”: [
“node_modules”
]
}


#8

Did this project start from Meteor 1.2.x and then update to 1.3.x before? Or start from 1.3.x?


#9

No I did the Tutorial Bootstrap just a few days ago.
Just started …trying… adding npm packages.
I do notice these packages have “module”: “commonjs”,
in their tsconfig.json… if that means anything.


#10

I have tried a half a dozen different ones … none work.


#11

So you mean this tutorial? Which step did you start to meet this issue? Step number?


#12

Just did…

npm install ng2-imageupload --save moment

consol: 31


#13

What do you mean? Did you succeed?


#14

It output 31 as you would expect. Does the module work? Hmmm,… i’ll see.


#15

Yeah, it means it works. Glad to hear that.
So I guess the issue may be related with ng2-uploader.


#16

Sorry… Does not work.

I tried this one. and example: https://www.npmjs.com/package/ng2-imageupload

Uncaught ReferenceError: System is not defined


#17

If I “just” do…

Then add
import * as moment from ‘moment’;

and use like
console.log(moment().daysInMonth());

it outputs 31 in the browser consol as you would expect.


#18

Because this package does not support common.js either:


#19

Before you use a package, please check how many stars they have on github.
You need make sure the package is in high quality and is maintained actively.


#20

I actually tried to do that for a module?