user12260140
user12260140

Reputation:

npm building issues for SyntaxHighlighter

I'm a beginner with npm and is trying to build SyntaxHighlighter version 4 by cloning it using git first, but failed. Here are the errors I got:

1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/name/syntaxhighlighter/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/bin/node" "/Users/name/syntaxhighlighter/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/name/syntaxhighlighter/node_modules/node-sass
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"0.10 || 0.12 || 4 || 5"} (current: {"node":"12.16.1","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN [email protected] No description

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/name/.npm/_logs/2020-04-05T02_52_17_048Z-debug.log

Upvotes: 3

Views: 1094

Answers (3)

Steven J. Ponessa
Steven J. Ponessa

Reputation: 15

robdonn's NVM solution works, however, I had a very unusual instance when running multiple versions of Node, managed through NVM, was breaking my ApiConnect/Loopback client (only on a Mac). I never figured out why but realize that running a single version of Node fixed the problem.

Also wanting to use syntaxhighlighter, I did manage to generate the syntaxhighlighter.js file using a Docker container. In the cloned directory I added the Dockerfile.

FROM node:5
# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

Thereafter I was able to:

  1. Build a local docker container
docker build -t syntaxhighlighter .
  1. Run the container mapping my local dist directory to the container's dist directory
docker run -i --volume ~/github/syntaxhighlighter/dist:/usr/src/app/dist syntaxhighlighter
  1. Got the container id for the local running container
docker ps
  1. Used the container id to go into the container (could have also just put CMD ['/bin/sh'] in my Dockerfile)
docker exec -it <the-container-id> /bin/sh
  1. Ran the gulp build from the Node v5 container. Since I am mapping my local dist directory to the container's dist directory, I get the output locally.
./node_modules/gulp/bin/gulp.js build --brushes=all  --compat

Upvotes: 1

robdonn
robdonn

Reputation: 260

The problem you are running into is that SyntaxHighlighter version 4 is too old and its dependencies are not supported by the version of Node you are running.

The package that the error is coming from is Karma. The version of Karma that is trying to install is v0.13.22. That version of Karma only supported a maximum Node version of 5, and you appear to be running version 12.

You could potentially solve this issue by downgrading your Node version, or using a tool like Node Version Manager (NVM) to temporarily downgrade your Node version.

NVM

Upvotes: 1

Zubad Ibrahim
Zubad Ibrahim

Reputation: 391

Try to install node_modules only. cd /syntaxhighlighter/node_modules$ and then try installing using npm install. There are some errors in gulp.js file that are causing problems in the installation process. I have tried older versions but none of them is available. Hope this will work out.

Upvotes: 0

Related Questions