The Electron forge project from publisher-github is failing to detect the environment variable GITHUB-TOKEN

I've set up my .env file with the correct token, but I encountered an error when trying to publish my package on GitHub. An unhandled rejection has occurred inside Forge: Error: Please set GITHUB_TOKEN in your environment to access these features at new GitHub

This is what I'm attempting to do:

  name: '@electron-forge/publisher-github',
  config: {
    repository: {
      owner: 'xxxxxx',
      name: 'xxxxxx'
    },
    prerelease: true,
    draft: true,
    authToken: process.env.GITHUB_TOKEN,
  }
}

Contents of .env file:

GITHUB_TOKEN=xxxxxxxxxxx

Answer №1

To ensure your environment variables are loaded, you will need to incorporate the dotenv package. It is important to note that it may not function properly within the electron-forge config file.

Alternatively, you can manually load the environment variable when executing the publish command:

export GITHUB_TOKEN=xxxxxxxxxxx && npm run publish

For Windows users, replace export with set:

set GITHUB_TOKEN=xxxxxxxxxxx && npm run publish

If needed, you can refer to this solution, which utilizes package.json commands to load env variables from a .env file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating to a new URL after submitting a form in React

Hello, I am new to React and have created a form that successfully sends data to Firebase. However, after submitting the form, I would like to redirect to /thankyou.html which is outside of the React app. Can someone please guide me on how to achieve this ...

Maintaining the order of subscribers during asynchronous operations can be achieved by implementing proper synchronization

In my Angular setup, there is a component that tracks changes in its route parameters. Whenever the params change, it extracts the ID and triggers a function to fetch the corresponding record using a promise. Once the promise resolves, the component update ...

Ways to retrieve a service variable within a delegated function (callback)

I am currently using a service that has a variable which needs to be updated by the service itself. However, I am facing an issue where I cannot access the variable in anonymous or delegated functions. (function() { 'use strict'; angular ...

Error encountered while attempting to retrieve an environment variable: Invalid token found

I am currently facing an issue while trying to add an environment variable inside the .env file in my Nuxt project. The version of Nuxt.js I am using is 2.15.3 Below is a snippet from my nuxt.config.js: export default { publicRuntimeConfig: { baseU ...

Updating NPM version from 5.8 to the most recent one

Considering updating NPM from version 5.8.0 to the newest version for a project I am currently involved in. I'm curious if it is possible to perform this update without causing any disruptions to the packages that are already installed. If there is a ...

Is there a way in Javascript to apply quotation marks to each value within an array individually?

I've created a function that retrieves and displays values from a CSV file. Here is the code for the function: var IDArr = []; var fileInput = document.getElementById("csv"); readFile = function() { console.log("file uploaded") var reader = new ...

I am unable to install electron using npm due to a group policy that restricts CMD execution in the %appdata% folder

Challenge Our team policies restrict the execution of cmd files from the windows %appdata% directory. When attempting to install electron, the following error occurs: npm install --save electron npm ERR! code 1 npm ERR! path C:\data\dev\dy ...

How do I use onclick to hide a <div> and reveal the content beneath it?

Is there a way for me to hide this <div> when the user clicks outside of it? I want the content behind it to be visible once the <div> is hidden. <html> <style> .overlay { position: fixed; top: 0; left: 0; height: ...

Storing JWT API tokens in a secure location

Currently, I am in the process of developing the API portion for an application and focusing on implementing JWT authentication. At this point, I am generating a token and sending it back to the front-end as part of a JSON object when a user is created. Ho ...

Tips for Viewing React.js Pages on Your Web Browser

Perhaps this question may sound silly, but as a React beginner, I have been using CDN Links and the "npx create-react-app" functions to build apps. Now, I have some supporting files for a book I am reading, and I want to view the chapters in a w ...

Steps for incorporating code to calculate the total price and append it to the orderMessage

I am seeking help with this program that my professor assigned to me. The instructions marked by "//" are the ones I need to implement in the code, but I'm struggling to understand how to proceed. Any assistance would be greatly appreciated, even just ...

javascript issue with onchange query

The JavaScript snippet below is included in the head section of my file. <?php echo "<script language='JavaScript'>\n"; echo "var times = new Array();\n"; echo "times[0] = 0;\n"; foreach($times as $time) { echo "times[". ...

Differences in React projects utilizing materialize-css compared to those using react-toolbox or material-ui

Is there a difference in technical benefits or code reliability when directly using material-css in JSX versus utilizing JSX specific libraries like material-ui or react-toolbox? Conversely, could using JSX libraries like material-ui or react-toolbox provi ...

What are alternative methods for creating a two-column form layout that do not involve the use of

When generating the html form, I am looping through the form variables as shown below: {% for field in form %} {{ LABEL }}{{ INPUT FIELD }} The labels and fields are going through a loop. A simple one-column layout can be generated using: {% for field ...

Implementing Javascript to insert IFRAME into the DOM

I'm looking to incorporate an iframe into my webpage. The iframe needs to link to a specific URL. I attempted to add the following code to my HTML, but it's not functioning as expected: document.createElement('<iframe src='http://ex ...

Prevent modal from closing when tapping outside of it

I'm currently facing a challenge in creating a popup modal that cannot be closed by clicking outside the modal window. I have explored various solutions involving backdrops but none of them seem to be effective. Any assistance would be greatly appreci ...

Adding automatic hyphens in dates within React

My goal is to create a date field in React, similar to the one on this page, with the date format of yyyy/mm/dd. This is my current approach: const [date_of_birth,setDateofBirth] = useState(""); const handleChangeDOB = (e) => { let value = e.target ...

How to delete the final element in a stack trace string using Javascript

Currently, I am working on a Javascript logger that includes the stack trace in error messages. The implementation looks like this: function logMessage(logMessage) { let stackTrace = new Error().stack; logMessage.stackTrace = stackTrace; ... } Whi ...

Inject the content loaded from the server into a div element, and insert that div at the

I am trying to insert the div(#loadmore) element inside the div(#boxchatting) element when the content from "result.php" is loaded into div(#boxchatting). Here is the code I used: $('#loadmore').prependTo('#boxchatting'); $('#boxc ...

The failure of jQuery AJAX error callback to execute

I'm currently facing an issue with an AJAX call that I have in my code. Here's the code snippet: $.ajax({ type: "get", url: "xxx.xxx.xxx/xxx.js", dataType: 'jsonp', success: function(data) { ...