npm

Building frontend fails with various (function undefined, etc.) errors

Now happening already two times in my career and spending some time with it, I find it worth telling my problem in this topic. After coming into a new company or to a new (existing) project you try to build the source code to start working on new features. A lot of times it happens that you receive error messages which do not happen on the colleagues work stations. Usually long working employees also fail to detect the root cause of this error. It actually comes from a differend node/npm version and errors from the build are very misleading. Since you (as newly come to the project) usually install a newer version of npm/node, the old backwards incompatible versions fail to build the code. So if it ever happens to you that you cannot build a newly downloaded source code, check the node version of the collegues!

I first installed cytoscape.js via npm. In the typescript-file (for Angular) I imported it by “import * as Cytoscape from 'cytoscape';”. And finally to use a Cytoscape instance I could store it in a variable by initializing it via “this.cy = Cytoscape({container: document.getElementById('cy'), … });”.

Import Javascript libraries into Angular 2

I had and still have not much experience in web engineering (Javascript, npm-Tool, …) when I started working with Angular 2. There I have a problem that normally one imports an angular-module with e.g. “import {Injectable} from '@angular/core';”. But I want to use the Javascript-library “cytoscape.js”. The problem now is, how to import it such that I can use it.
Subscribe to npm