How to run require(“express”); from a TypeScript Angular Component in Electron App

眉间皱痕 提交于 2019-12-13 03:43:38

问题


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:


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

const express = require('express');
// OR
import * as express from 'express';


来源:https://stackoverflow.com/questions/47993447/how-to-run-requireexpress-from-a-typescript-angular-component-in-electron-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!