Closed otto2me closed 3 years ago
This package is designed for Node environment. It depends on other packages also designed for Node. I would recommend to try another Jira client if you want to use in a browser.
Yes, I use node, as mentioned above in version Node: 12.20.1. Via node/npm I installed all packages (angular and jira-client)
Sorry what I meant is node-jira-client
can't work in the browser. Instead, it's suitable for a Node server, Node script...
Ok, now I try to use electron as my node environment, using inside electron/main.js this option: mainWindow = new BrowserWindow({width: 800, height: 600, webPreferences:{nodeIntegration:true, enableRemoteModule:true}})
However, my window is still empty.
I would need more infos than my window is still empty
if you want me to help.
@otto2me could you provide a repo with the minimum setup to demonstrate the issue?
Here we go, a simple app using electron. When you start it, you get only a Hello World. If you deactivate the new instance of JiraApi inside app.component.ts then you see the default page complete.
I checked quickly the source. You're still trying to use in a browser environment.
import { Component } from "@angular/core";
import * as JiraApi from "jira-client";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
title = "SyncTool";
jira: any;
// initialize the jira connection with user's username and password
// return the user if successful, return error if unsuccessful
async init(username, password, host = "jira.myserver.com") {
this.jira = new JiraApi({
protocol: "https",
host: host,
username: username,
password: password,
apiVersion: "2",
strictSSL: false,
});
return this.jira
.getCurrentUser()
.then((user) => {
// console.log(user);
return user;
})
.catch((err) => {
// this.logError(err);
return err;
});
}
}
Use it in src/electron
or find a way to leave the Node API intact in your Angular component. The ng
CLI is probably transforming modules that you import to make them work in a browser environment. node-jira-client
still won't work in this case.
I won't help you further more except if you're using the module as intended, i.ie in a Node environment.
Sorry, but I am everything but an expert in this programming language. It is difficult to understand the difference between a browser and a pure node environment. I like to write an application running on my desktop to access our Jira in order to automate various functions. I thought using the node-jira-client would be a good idea to achieve this. But what does it mean? Can I not use angular gui elements for my application? Is a node application only a backend? Running the application as a desktop version requires some sort of container. I thought electron would be a good choice. My understanding is that I configured electron such, that it behaves like a node environment?
@otto2me You can search for "electron main process renderer process" to understand how Electron works (see https://cameronnokes.com/blog/deep-dive-into-electron's-main-and-renderer-processes/ for example).
Your Angular app runs in the renderer process (~ browser environment). It is possible to have Node features in the renderer process by setting nodeIntegration: true
BUT if your Angular app is bundled, the bundler must know that you target an Electron environment where Node features are available. My guess is that your bundler doesn't know that so it mocks/shims the Node features.
I am sorry too, I am not expert in Electron/Angular so it's difficult to resolve your problem. This place is dedicated node-jira-client
. I need to draw the line. I am not going to debug your project and explain you Electron when it's clear that you're not using the package in a way it was designed for.
Hi,
I have setup a fresh angular: Angular CLI: 10.2.3 Node: 12.20.1 OS: win32 ia32
Next I created a fresh project and installed jira-client.
Running the default angular app.component.html on http://localhost:4200/ works fine. However, now I add to app.component.ts
import JiraApi from 'jira-client'; jira = new JiraApi({ protocol: 'https', host: 'jira.somehost.com', username: 'username', password: 'password', apiVersion: '2', strictSSL: true });
This now creates many error messages like: ERROR in ./node_modules/tunnel-agent/index.js Module not found: Error: Can't resolve 'http' in 'MYPATH\angular10-example\node_modules\tunnel-agent'
ERROR in ./node_modules/forever-agent/index.js Module not found: Error: Can't resolve 'https' in 'MYPATH\angular10-example\node_modules\forever-agent'
Installing the packages does not solve the issue, but adding this section to my package.json does: "browser": { "zlib": false, "http": false, "https": false, "crypto": false, "fs": false, "tls": false, "os": false, "net": false, "timers": false }
However, no it comilies fine, but my webpage is empty, no error message is seen and no content.
How do I need to setup my project correctly in order to use jira-client?