我正在開發電子應用程序使用Angular2。來自Angular2內部的節點和電子模塊
在我引用/電子的main.js
裝載NG應用程序:
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
let win
function createWindow() {
win = new BrowserWindow({width: 800, height: 600})
// load the index.html of the NG app:
win.loadURL(url.format({
pathname: path.join(__dirname, '/../../dist/index.html'),
protocol: 'file:',
slashes: true
}))
[...]
這就像一個魅力。但是,我現在想要在NG部分內訪問節點和電子模塊。
當我嘗試導入例如:在fs
模塊,如:
import * as fs from "fs";
它仍然編譯,但每當我打電話fs.readFile(...)
它說:
__WEBPACK_IMPORTED_MODULE_2_fs__.readFile is not a function
當我仔細想想,這不併且無法工作,因爲這些模塊不在node_modules
文件夾內(右側?)。 我需要做些什麼才能使它們在NG部件內部可用?
不幸的是我甚至不能訪問'electron'模塊加載從'remote':'從「電子」進口{}遠程;'拋出:'找不到名稱' electron'' – cocoseis