Skip to content

NPM and TypeScript support

NPM support

Install npm

Enable npm in a project

  • Right-click the project → Add NPM support
  • A package.json is created in the project root when done
  • Run npm install <package-name> in the project directory, e.g. npm install md5 — follow the package’s official usage

Notes

  • npm packages target different runtimes (web, Node, etc.). EC standalone uses JavaScriptCore — pure JS only; choose pure-JS packages
  • Not every npm package is supported

TypeScript support

Install TypeScript

Enable TypeScript in a project

  • Right-click the project → Add TypeScript support
  • A tsconfig.json is created and .d.ts references are generated for JS under libs

TypeScript in the js folder

  • JS under js is used directly — no require; do not use export, but you can reference other JS files
  • Write .ts in js, e.g. Card.ts — saving generates Car.d.ts and Card.js for use in other JS files
// File: js/Car.ts
class Car{
test():void{
logd("i am car.")
}
}
  • Call from other JS:
// File: js/main.js
function main(){
let car = new Car();
car.test()
}

TypeScript in the ts folder

  • Files under ts must export and be loaded with require
// File: ts/Car1.ts
class Car1{
test1():void{
logd("i am car1.")
}
}
export ={Car1}
  • Call from JS:
// File: js/main.js
function main(){
let car = require("ts/Car1")
let car1 = new car.Car1();
car1.test1()
}

JS and TS mixed development