Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building: loadReposFromCache(...).error is not a function #428

Open
rhergenreder opened this issue Nov 10, 2017 · 16 comments
Open

Building: loadReposFromCache(...).error is not a function #428

rhergenreder opened this issue Nov 10, 2017 · 16 comments

Comments

@rhergenreder
Copy link

rhergenreder commented Nov 10, 2017

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. (/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.

@OniDaito
Copy link

Seconded. Using npm 5.4.2 on arch linux

@manbearwolf
Copy link

manbearwolf commented Nov 15, 2017

Download Theme for (--theme=default) (https://github.com/syntaxhighlighter)
gulp build --brushes=all --theme=default
maybe helps, for now. Anyone know if brushes are missing from the gulp setup-project. (line)? (Maybe works)?...

@m-hatch
Copy link

m-hatch commented Nov 22, 2017

I get this error also. Using Windows 7, npm 3.10.10

$ ./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'

@ma-si
Copy link

ma-si commented Nov 27, 2017

On linux

$ git clone https://github.com/syntaxhighlighter/syntaxhighlighter.git
$ cd syntaxhighlighter
$ npm install
$ gulp setup-project
[12:09:37] Starting 'setup-project:clone-repos'...
[12:09:37] 'setup-project:clone-repos' errored after 1.52 ms
[12:09:37] TypeError: loadReposFromCache(...).error is not a function
    at loadRepos
    ...
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '.projects-cache.json'

@soluml
Copy link

soluml commented Dec 8, 2017

Running into the same issue. It's compounded by the fact that the NPM package seems to have exporting errors when used within Webpack. Anyone find a work around?

@m-hatch
Copy link

m-hatch commented Dec 8, 2017

I have posted a stackoverflow question concerning this issue here: https://stackoverflow.com/q/47438759/4084574

@CHN-STUDENT
Copy link

CHN-STUDENT commented Dec 11, 2017

I meet same issue when i try to build on Windows 10 or CentOS 7.
Here are the error info on CentOS 7 :

[root@localhost syntaxhighlighter]# ./node_modules/gulp/bin/gulp.js setup-project
[20:09:29] Failed to load external module @babel/register
[20:09:29] Requiring external module babel-register
[20:09:29] Using gulpfile ~/syntaxhighlighter/gulpfile.babel.js
[20:09:29] Starting 'setup-project:clone-repos'...
[20:09:29] 'setup-project:clone-repos' errored after 748 μs
[20:09:29] TypeError: loadReposFromCache(...).error is not a function
    at loadRepos (/root/syntaxhighlighter/build/setup-project.js:39:48)
    at Gulp.<anonymous> (/root/syntaxhighlighter/build/setup-project.js:48:5)
    at module.exports (/root/syntaxhighlighter/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/root/syntaxhighlighter/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/root/syntaxhighlighter/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/root/syntaxhighlighter/node_modules/orchestrator/index.js:134:8)
    at /root/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:678:11)
(node:3817) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/root/syntaxhighlighter/.projects-cache.json'
(node:3817) [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.

On Windows 10 by Git Shell:

$ gulp  setup-project
[20:25:50] Failed to load external module @babel/register
[20:25:50] Requiring external module babel-register
[20:25:53] Using gulpfile ~\Documents\GitHub\syntaxhighlighter\gulpfile.babel.js
[20:25:53] Starting 'setup-project:clone-repos'...
[20:25:53] 'setup-project:clone-repos' errored after 1.32 ms
[20:25:53] TypeError: loadReposFromCache(...).error is not a function
    at loadRepos (C:/Users/Mr.Guo/Documents/GitHub/syntaxhighlighter/build/setup-project.js:39:48)
    at Gulp.<anonymous> (C:/Users/Mr.Guo/Documents/GitHub/syntaxhighlighter/build/setup-project.js:48:5)
    at module.exports (C:\Users\Mr.Guo\Documents\GitHub\syntaxhighlighter\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\Users\Mr.Guo\Documents\GitHub\syntaxhighlighter\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\Users\Mr.Guo\Documents\GitHub\syntaxhighlighter\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\Users\Mr.Guo\Documents\GitHub\syntaxhighlighter\node_modules\orchestrator\index.js:134:8)
    at C:\Users\Mr.Guo\AppData\Roaming\npm\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:678:11)
(node:71856) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:\Users\Mr.Guo\Documents\GitHub\syntaxhighlighter\.projects-cache.json'
(node:71856) [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.

Also,i see the people meet same issues on StackOverFlow.

@tmosest
Copy link

tmosest commented Dec 14, 2017

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.

@rfqu
Copy link

rfqu commented Dec 15, 2017

I met this issue too, does any fix that?
[17:08:26] TypeError: loadReposFromCache(...).error is not a function at loadRepos (F:/Cloud/git/opensource/syntaxhighlighter/build/setup-project.js:39:48) at Gulp.<anonymous> (F:/Cloud/git/opensource/syntaxhighlighter/build/setup-project.js:48:5) at module.exports (F:\Cloud\git\opensource\syntaxhighlighter\node_modules\orchestrator\lib\runTask.js:34:7) at Gulp.Orchestrator._runTask (F:\Cloud\git\opensource\syntaxhighlighter\node_modules\orchestrator\index.js:273:3) at Gulp.Orchestrator._runStep (F:\Cloud\git\opensource\syntaxhighlighter\node_modules\orchestrator\index.js:214:10) at Gulp.Orchestrator.start (F:\Cloud\git\opensource\syntaxhighlighter\node_modules\orchestrator\index.js:134:8) at F:\Cloud\git\opensource\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:5400) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'F:\Cloud\git\opensource\syntaxhighlighter\.projects-cache.json'

@maicss
Copy link

maicss commented Jan 25, 2018

@qfocus your file is 'F:\Cloud\git\opensource\syntaxhighlighter\.projects-cache.json', .projects-cache.json seems the file name should not starts with a dot?

@maicss
Copy link

maicss commented Jan 25, 2018

Why depends package @babel/register, and it is not list in package.json?

➜  syntaxhighlighter git:(master) ✗ ./node_modules/gulp/bin/gulp.js build --brushes=../xmlBrush/brush.js  --theme=default
[18:04:51] Failed to load external module @babel/register
[18:04:51] Requiring external module babel-register
[18:04:51] Using gulpfile ~/Development/syntaxhighlighter/gulpfile.babel.js
[18:04:51] Starting 'build'...
[18:04:51] TypeError: Promise.props is not a function
    at /Users/mac/Development/syntaxhighlighter/build/bundle.js:75:27
    at <anonymous>

@karljacuncha
Copy link

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:
karljacuncha@dc015fa

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

@nstublen
Copy link

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.

@crazy-max
Copy link

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

@AustinTSchaffer
Copy link

AustinTSchaffer commented Apr 1, 2019

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.

@racerxdl
Copy link

racerxdl commented Sep 8, 2019

Thanks @AustinTSchaffer . That Indeed worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests