How to run require(“express”); from a TypeScript A

2019-08-26 11:20发布

I'm new to "Angular", "typescript" and "Electron". I created a "server.js" file with the basic example of express. What is the correct way to create a local server for the local network?

I want to create an "Angular" "Electron" App with a button to run the express server, but I don't know what to code in order to execute the "server.js" file.

function runLocalServer() {

  servidor = require('server.js');  // This line is a error!

  ....

Thanks for your help.

1条回答
时光不老,我们不散
2楼-- · 2019-08-26 11:30

TypeScript accepts a normal require() as well as the import syntax. For example:

const express = require('express');
// OR
import * as express from 'express';
查看更多
登录 后发表回答