如何运行require("express");从Electron App中的TypeScript角度组件获取 [英] How to run require("express"); from a TypeScript Angular Component in Electron App

查看:63
本文介绍了如何运行require("express");从Electron App中的TypeScript角度组件获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是"Angular",打字稿"和"Electron"的新手.我使用 Express的基本示例创建了一个"server.js"文件.为本地网络创建本地服务器的正确方法是什么?

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?

我想创建一个带有按钮的"Angular""Electron"应用程序来运行快递服务器,但是我不知道要执行"server.js"文件要编写什么代码.

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!

  ....

感谢您的帮助.

推荐答案

TypeScript接受常规的 require() import 语法.例如:

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

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

这篇关于如何运行require("express");从Electron App中的TypeScript角度组件获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆