syntaxhighlighter: Building: loadReposFromCache(...).error is not a function

I get the following error when running ./node_modules/gulp/bin/gulp.js setup-project:

[16:44:12] Requiring external module babel-register [16:44:12] Using gulpfile /tmp/syntaxhighlighter/gulpfile.babel.js [16:44:12] Starting ‘setup-project:clone-repos’… [16:44:12] ‘setup-project:clone-repos’ errored after 788 μs [16:44:12] TypeError: loadReposFromCache(…).error is not a function at loadRepos (/tmp/syntaxhighlighter/build/setup-project.js:39:48) at Gulp.<anonymous> (/tmp/syntaxhighlighter/build/setup-project.js:48:5) at module.exports (/tmp/syntaxhighlighter/node_modules/orchestrator/lib/runTask.js:34:7) at Gulp.Orchestrator._runTask (/tmp/syntaxhighlighter/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/tmp/syntaxhighlighter/node_modules/orchestrator/index.js:214:10) at Gulp.Orchestrator.start (/tmp/syntaxhighlighter/node_modules/orchestrator/index.js:134:8) at /tmp/syntaxhighlighter/node_modules/gulp/bin/gulp.js:129:20 at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:655:11) (node:18176) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open ‘/tmp/syntaxhighlighter/.projects-cache.json’ (node:18176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I followed exactly the steps described at https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Building. Using npm 5.5.1-1 on ArchLinux. I also tried installing the git and github module manually, but nothing changed.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 7
  • Comments: 16

Most upvoted comments

Here’s what worked for me…

After installing npm dependencies, go into node_modules/songbird/lib/songbird.js and change

Promise = global.Promise || require("bluebird");

to

Promise = require("bluebird");

This will make sure the extensions for Promise are available.

I’ve used @nstublen workaround to create a docker image to build syntaxhighlighter and also add custom brushes / themes if you want to take a look : https://github.com/crazy-max/docker-syntaxhighlighter

I fixed this issue by changing .error in the following line to .catch

const loadRepos = () => loadReposFromCache().error(loadReposFromGitHub).then(R.map(R.pick([‘ssh_url’, ‘name’])));

Line 39 of setup-projects.js

However there were other things that I had to do to get a full build working.

Hey folks, came up with a quick workaround since I’m just trying to get a basic build working and I know more about Python than I do about Node. This probably only works on any Linux, regardless of Python version, but I have only tested my personal Ubuntu. You can probably change the calls to os.symlink to some form of subprocess.call to get it working on Mac or Windows.

Dump the following code into a setup-this-project-without-node.py in the root directory of the project and run it however you’d like. It performs the exact same steps that the gulp setup-project does.

import urllib
import json
import os
import subprocess

project_dir = os.path.dirname(os.path.realpath(__file__))
api_url = 'https://api.github.com/orgs/syntaxhighlighter/repos?per_page=300'
repos = json.load(urllib.urlopen(api_url))

for repo in repos:
  if repo['name'] != 'syntaxhighlighter':

    # Clones the repo into the repos directory
    subprocess.call([
      'git', 'clone', repo['clone_url'],
      os.path.join('repos', repo['name'])
    ])

    # Links the project's node_modules into each repo
    src1 = os.path.join(project_dir, 'node_modules')
    dest1 = os.path.join(project_dir, 'repos', repo['name'], 'node_modules')
    if not os.path.exists(dest1):
      os.symlink(src1, dest1)

    # Links each repo into the project's node_modules
    src2 = os.path.join(project_dir, 'repos', repo['name'])
    dest2 = os.path.join(project_dir, 'node_modules', repo['name'])
    if not os.path.exists(dest2):
      os.symlink(src2, dest2)

After applying @nstublen 's fix to songbird.js, I was able to run a successful build.

This looks to be part of a batch of issues with Promises in the setup-project and bundle scripts.

I’ve got this to build and committed to a fork here: https://github.com/karljacuncha/syntaxhighlighter/commit/dc015fa299d4d249e8518664e205a838c55372cf

For this specific issue, you could remove/skip the loadReposFromCache, and always load from GitHub Repo:

build/setup-project.js, line 37:
  // const loadReposFromCache = () => fs.readFile.promise(REPOS_CACHE, 'utf8').then(JSON.parse);
  // const loadRepos = () => loadReposFromCache().error(loadReposFromGitHub).then(R.map(R.pick(['clone_url', 'name'])));
  const loadRepos = () => loadReposFromGitHub().then(R.map(R.pick(['clone_url', 'name'])));

This will still crap out, but you should have enough to move onto the build at that stage