Syntax Error: The function `loadReposFromCache(...).error` is not defined in this building

I'm currently attempting to utilize the SyntaxHighlighter v4 plugin, but I'm facing issues with the build process!

While following the guidelines provided here, an error popped up:

$ ./node_modules/gulp/bin/gulp.js setup-project
[10:12:20] Requiring external module babel-register
[10:12:20] Using gulpfile C:\git\syntaxhighlighter\gulpfile.babel.js
[10:12:20] Starting 'setup-project:clone-repos'...
[10:12:20] 'setup-project:clone-repos' errored after 1.96 ms
[10:12:20] TypeError: loadReposFromCache(...).error is not a function
    at loadRepos (C:/git/syntaxhighlighter/build/setup-project.js:39:48)
    at Gulp.<anonymous> (C:/git/syntaxhighlighter/build/setup-project.js:48:5)
    at module.exports (C:\git\syntaxhighlighter\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:134:8)
    at C:\git\syntaxhighlighter\node_modules\gulp\bin\gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:606:11)
(node:2532) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:\git\syntaxhighlighter\.projects-cache.json'

It appears that the github repository files are not being imported to the /repos/ directory. Is there a manual way to do this? Or perhaps an alternative method to successfully build and use it? Maybe even locate the built files similar to v3?

Below is the problematic function in build/setup-project.js

gulp.task('setup-project:clone-repos', 'Clones all repositories from 
  SyntaxHighlighter GitHub organization', () =>
    loadRepos()
      .then(R.filter(repo => !fs.existsSync(pathToRepo(repo))))
      .then(R.filter(repo => repo.name !== 'syntaxhighlighter'))
      .then(R.map(R.curry(cloneRepo)))
      .then(Promise.all)
);

Following along backwards we find:

const loadReposFromCache = () => fs.readFile.promise(REPOS_CACHE, 'utf8').then(JSON.parse);
const loadRepos = () => loadReposFromCache().error(loadReposFromGitHub).then(R.map(R.pick(['clone_url', 'name'])));

function loadReposFromGitHub() {
  const request = require('request');

  const opts = {
    url: 'https://api.github.com/orgs/syntaxhighlighter/repos?per_page=300',
    json: true,
    headers: { 'User-Agent': 'node.js' },
  };

  return new Promise((resolve, reject) =>
    request(opts, (err, response) => {
      if (err) return reject(err);
      const json = response.body;
      fs.writeFile(REPOS_CACHE, JSON.stringify(json, null, 2));
      resolve(json);
    })
  );
}

Answer №1

There seem to be a few issues with the build code for that particular project.

One specific issue is that the Songbird wrapper on Bluebird promises no longer seems to be compatible, resulting in the error message ".error is not a function" (works fine on Bluebird).

To resolve this, you can either replace .error with .catch or switch from using require('songbird') to require('bluebird').

However, fixing this issue is just the beginning of the challenges you may encounter during the build process...

I have made a note of this issue in the project's tracking system. In the meantime, here is what I did to successfully build it: https://github.com/karljacuncha/syntaxhighlighter/commit/dc015fa299d4d249e8518664e205a838c55372cf

Answer №2

Once again, the build has encountered issues in April 2021. I took inspiration from karljacuncha's response and made modifications by replacing the call to fs.writeFile with fs.writeFileSync

To view the changes made, visit https://github.com/BartJolling/syntaxhighlighter/commit/7dbd08203cba8ef3be72cbe1abbfb3475be19ef4

In addition to this, I have implemented several other fixes that were suggested within the community. Furthermore, I have rectified the usage of the -output parameter.

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

performing a jQuery AJAX call from a UIWebView during the initial launch of the app following installation

We have a uiWebview that uses jquery for an ajax request to log in. It functions flawlessly on mobile safari and all browsers. However, when the application is launched for the first time after installation, the ajax request seems to be sent out but no re ...

Incorporate content from HTML into various sections

Is there a way to dynamically extract the h4 headers and the first sentence from each section of this HTML, and then add them to a new div? function summarize() { let headings = document.getElementsByTagName("h4"); // Get all H4 elements let newsText = do ...

Starting Web Server using File (file://) protocol

I'm currently using Quasar to develop a Vue SPA web app/page. For this project, the web app will only run by clicking on the index.html file generated by the Quasar packager. This package will not be distributed online or hosted on any domain. My mai ...

Leverage the power of Node.js by utilizing http.get along with

I have been working on integrating a library (available here) into my project, which is capable of generating QR codes and various other types of codes. My current issue revolves around making a request where I can access both the req and res objects in o ...

What steps should I take to solve this wheel-related issue in my Vue 3 application?

I have been developing a Single Page Application (SPA) using Vue 3, TypeScript, and The Movie Database (TMDB). Currently, I am tackling the implementation of a search feature and I've encountered a bug. The "search-box" component is located in src&b ...

How can I incorporate a material-ui component using innerHTML?

Hi there, I'm new to using React and StackOverflow. I've been attempting to incorporate a Button component from material-ui by utilizing document.getElementById.innerHTML. However, upon the appearance of the button, the material-ui styling fails ...

Tips for fetching data from a database using AJAX when the values of two drop-down lists are involved

I have successfully implemented an Example where I retrieve data using a single drop-down list from a database. Now, I want to extend this functionality to work with two drop-down lists, where the values retrieved from the database are dependent on the sel ...

Using the .each() method in jQuery to dynamically assign an attribute to a parent element in JavaScript

I'm new to JavaScript and jQuery and I need help transitioning my code from jQuery to pure JS. Within my HTML, there are multiple parent divs each containing a child div. My goal is to assign a class to both the child and parent elements, with the p ...

How can I modify the parent form element to only evaluate the expression at the text node, without affecting Angular interpolation?

Currently, I am in the process of developing an eCommerce platform and utilizing angular to construct a widget on product detail pages. Unfortunately, my control over the initial HTML rendered for the browser is quite limited. While most tasks related to m ...

Ember.js: Storing function prototypes as objects

My interface consists of four vertical panels: The first panel displays the menu for selecting data The second panel allows you to choose a filter from a list The third panel shows the results based on the selected filter The fourth panel displays detail ...

Countdown to redirect or exit on Jquery mobile "pageshow" and "pagehide" events

Looking to implement a 30-second countdown on a Jquery Mobile page with specific requirements: (1) Countdown begins on pageshow (2) Redirects to new page when countdown expires (3) If user navigates away (pagehide) before countdown finishes, the timer fun ...

Customizing MUI DataGrid: Implementing unique event listeners like `rowDragStart` or `rowDragOver`

Looking to enhance MUI DataGrid's functionality by adding custom event listeners like rowDragStart or rowDragOver? Unfortunately, DataGrid doesn't have predefined props for these specific events. To learn more, check out the official documentati ...

Display a div in JQuery along with all of its associated label elements

Here is my HTML code: <div id="summarySpan" style="padding-left: 20px" hidden> <label id="currentStatusSummary" style="padding-left: 20px" /> <br /> <label id="currentMonitoringSummary" style="padding-left: 20px" /> < ...

Execute JavaScript script whenever the state changes

I have a large table with multiple HTML elements such as dropdowns, textboxes, radio buttons, and checkboxes. Additionally, I have a function that I want to execute whenever any of these items change. Whether it's a selection from a dropdown, typing i ...

In order to extract a value from a different webpage, I must first make a request to that webpage and extract the XML value from it

I have been working on a project that requires displaying currency exchange rates. To achieve this, I initially tried using AngularJS to call another webpage for the exchange rate values, but I encountered issues as AngularJS can only make JSON/Rest URL ca ...

Using asynchronous functions in a loop in Node.js

Although this question may have been asked before, I am struggling to understand how things work and that is why I am starting a new thread. con.query(sql,[req.params.quizId],(err,rows,fields)=>{ //rows contains questions if(err) throw err; ...

Navigate to the correct page when the Button is clicked in a ReactJS/Django project

Embarking on my web development journey, I opted for django/Reactjs to build a social network platform. I created several API methods like account/view_user/ to retrieve a list of users and account/view_user/ for specific user attributes. In React, I cra ...

Adding HTML elements dynamically using jQuery: A how-to guide

My objective is to start with one element upon loading the page, and this element should have an ID of "something_O". When the user clicks on an add link, a new identical HTML element should be added underneath the existing element. The new element should ...

Is there a way to illuminate a complete row by simply hovering over a span within one of the columns?

If I want to change the background-color of a div with classes "row" and "highlightThisRow" when hovering over a span with the class "fromThisSpan", how can I achieve that? In a list, there are multiple rows with several columns. The span in question is l ...

Implementing a dynamic loading strategy for Google reCAPTCHA based on language selection

I have a unique application that requires the selection of one language out of four options (English, French, Dutch, español) in a form. Below the language selection, the Google reCaptcha is displayed. I am looking to dynamically load the reCaptcha scrip ...