syntaxhighlighter / syntaxhighlighter

SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript.
MIT License
5.33k stars 1.28k forks source link

How to build on Windows 10? #385

Open appetere opened 8 years ago

appetere commented 8 years ago

I'm trying to follow the building instructions using Windows 10. But I get warnings / failures at various points.

Below is the out-of-the-box experience, with the problems shown.

The first issue seems to be the use of ln to create links, which Windows doesn't understand. I did try running the script in Powershell (hoping it had a mapped command for ln) but this didn't work. Also tried editing the point where ln is called to use mklink instead, but this didn't seem to solve the problem either.

So my question is whether there is a way to build this on Windows 10? I am new to npm and gulp, so am wondering if I have missed something obvious?

Steps I followed:

Using Command prompt, as administrator.

npm install Issues warnings at start: capture And warnings at end: capture2

gulp setup-project Fails when ln is called: capture3 capture5 capture6

yumetodo commented 8 years ago

@appetere

gulp setup-project

How does it work when running on git bash(ex. comes with the SourceTree)?

appetere commented 8 years ago

@yumetodo Using git bash (still on Windows 10) from a fresh clone of the repo, I get the following:

npm install Same warnings.

gulp setup-project Runs without reporting any errors.

gulp build Errors as: capture8

yumetodo commented 8 years ago

gulp build

same issue on Windows7x64.

>gulp build --brushes=all --theme=midnight
[03:15:46] Requiring external module babel-register
[03:15:49] Using gulpfile ~\Documents\syntaxhighlighter\gulpfile.babel.js
[03:15:49] Starting 'build'...
[03:15:50] Error: File to import not found or unreadable: theme-base.scss
Parent style sheet: stdin
    at options.error (C:\Users\yumetodo\Documents\syntaxhighlighter\node_modules\node-sass\lib\index.js:277:32)

./node_modules./node-sass./lib./index.js

  // options.error and options.success are for libsass binding
  options.error = function(err) {
    var payload = util._extend(new Error(), JSON.parse(err));//this line.

    if (cb) {
      options.context.callback.call(options.context, payload, null);
    }
  };
alexgorbatchev commented 8 years ago

hm... can you tell me if ./repos folder get populated after gulp setup-project and if it has theme-base/theme-base.scss file?

appetere commented 8 years ago

Yes to both questions for me on Windows 10, after running gulp setup-project from git bash.

./repos has 49 directories.

alexgorbatchev commented 8 years ago

thanks for checking! what about ./node_modules/theme-base/theme-base.scss?

appetere commented 8 years ago

Ah-ha - that's not there. No ./node_modules/theme-base directory at all.

I have 555 items in the ./node_modules directory.

alexgorbatchev commented 8 years ago

hm... during gulp setup-project a bunch of symlinks are placed into the node_modules folder... I'm really not sure what happens on windows. You could try npm install theme-base... there might be a few other things that will be missing, in that case can also npm install them. I'm not really sure what the right approach for windows build would be.

What do you think?

appetere commented 8 years ago

I had to give up trying to make it build on Windows, as don't have enough knowledge.

I have tried spinning up an Ubuntu instance on Amazon EC2, but again it won't build out of the box.

sudo gulp setup-project fails initially with /usr/bin/env: node: No such file or directory. This I managed to get round by using sudo update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100

Running setup-project again then gives: capture

I am a newcomer to Unix, so realise I might be doing something wrong. But is there a particular flavour of Unix that the build-scripts should work on out of the box?

Using Amazon EC2 I have a choice (in the free tier) of

Any suggestions on which to use, or where else to build this? I don't have access to an Apple Mac unfortunately.

yumetodo commented 8 years ago

I think this projecct shoud publish pre-build files because this project is passing travis-cl. To fundamentally solve the issue like "I fail to build this. How to do?", it is only way, I think.

appetere commented 8 years ago

@alexgorbatchev Just to let you know I've just spent a couple of hours switching my software development blog to use Prettify from Google instead of SyntaxHighlighter.

The way you install this is very similar to SyntaxHighlighter v3, so very easy to do. I would have liked to have tried out your v4, which I'm guessing is just as good as Prettify, but I just couldn't work out how to build the project, to get the JavaScript and CSS I would need.

japj commented 8 years ago

I have a couple of questions related to the problem of building on windows and how this is currently setup in syntaxhighlighter:

Loud2004 commented 7 years ago

I know this is old, but the bug is still there. Here is the solution:

The problem is with making symbolic links under Windows. After trying to run 'setup-project' you can see the script trying to create dozens of symbolic links before giving an error message. There are three problems:

  1. Windows uses mklink /D and not ln -s
  2. Windows reverses the order of the command e.g. mklink /D Link Target instead of ln -s Target Link
  3. Windows uses backslash not forward slash. The script tries to append each directory using forward slashes.

Temporary Solution: Open command prompt as Administrator. Create all links by hand, one by one. Every one that you need is listed during 'setup-project'. Then you can run 'build'

MayaLekova commented 7 years ago

Another solution which worked well for me on Windows 10 is having the Windows Subsystem for Linux installed.

bitnoodle commented 7 years ago

following up on Loud2004, here's a simple CMD script to make the links for you. Copy to a mklinks.cmd file in your top-level syntaxhighlighter folder and run from there.

@echo off for /D %%G in (repos\*) do call :linkdir %%~nG @echo on exit /b

:linkdir rmdir /s /Q node_modules\%1 mklink /D %CD%\node_modules\%1 %CD%\repos\%1 rmdir /s /Q repos\%1\node_modules mklink /D %CD%\repos\%1\node_modules %CD%\node_modules exit /b

ihatem commented 7 years ago

you have to run ./node_modules/gulp/bin/gulp.js setup-project to setup all the files in "./repos" folder before building

crazy-max commented 6 years ago

Hi guys, to solve this issue I've created a docker image to build syntaxhighlighter easily. You can also add custom brushes / themes : https://github.com/crazy-max/docker-syntaxhighlighter

fanling521 commented 6 years ago

hello