npm building issues for SyntaxHighlighter - node.js

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 karma#0.13.22: 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: karma#0.13.22
npm WARN syntaxhighlighter#4.0.1 No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#3.13.1 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

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

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.

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:
Build a local docker container
docker build -t syntaxhighlighter .
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
Got the container id for the local running container
docker ps
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
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

Related

node-gyp rebuild fails on Mac OS High Sierra while npm install

I am getting following error in the terminal, while it tries to install one of package "node-expat". I have tried switching to different node version using nvm but still it is failing with same error.
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/node-expat
npm ERR! node v6.5.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! node-expat#2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat#2.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-expat
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\<redacted>\npm-debug.log
I went ahead installing x-code as suggested on git hub page, on my machine and then it is giving following error,. Not sure how to debug further.
xcode-select: error: tool 'xcodebuild' requires Xcode,
but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
I just got it fixed on my machine and my fellow colleagues machine.
Followed the following steps to fix it on MacOS highSierra 10.13:
Downloaded command line tools (MacOS 10.13) for xcode and installed it.
Download it from "https://developer.apple.com/download/more/"
Installed xcode 10.0 from the app store. Opened xcode and went through the regular configuration xcode does in the initial start up.
After this it started giving "xcode-select" path issue as stated in the description above. On running command "xcode-select --print-path" it was showing path as '/ Library/Developer/CommandLineTools', so i went ahead and tried "xcode-select --reset" after which the path changed to "/Applications/Xcode.app/Contents/Developer".
Immediately after it the build started working without any issues.
Solution above mentioned by Luke worked partially for me (MacOS) but created another issue :
gyp ERR! stack Error:makefailed with exit code: 2 which was solved by removing locked json file. Issue was created due to permission in MAC OS. So if you have xcode re-installed already, open terminal (command line) and type:
xcode-select --reset
then go to your project folder and remove:
package-lock.json
Now in terminal reinstall project :
npm install
I hope this helps someone!

NPM run dev command always fails at "grunt develop:quick" script

Using a cloned repository, I am trying to run npm run dev in order to develop locally. I have installed the grunt commands globally and my npm is recently updated. A possible problem I can see is that my node.js is at 5.10. However, if possible, I'd like to keep it there due to other team members having history with the repository not working on updated versions of node.js. The root of my repository is saved in the web folder and this is through Windows PowerShell(Admin).
PS C:\Users\<User>\Documents\GitHub\web> npm run dev
> web#12.5.6 dev C:\Users\<User>\Documents\GitHub\web
> grunt develop:quick
Running "develop:quick" (develop) task
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "copy:modules" (copy) task
Copied 24 files
Running "base-sass-config" task
Interim sass config file [client\styles\core\__config.scss] created.
Running "glob-sass-components" task
Traversing:
C:\Users\oalyousf\Documents\GitHub\web\client\src\components\pages
Traversing:
C:\Users\oalyousf\Documents\GitHub\web\client\src\components\building-blocks
Interim components glob file [client\styles\core\__components.scss] created.
Running "sass:static" (sass) task
>> File to import not found or unreadable: ....srcomponentspages­min-
consolestyles­min-console.scss
>> Parent style sheet:
C:/Users/<User>/Documents/GitHub/web/client/styles/core/__components.scss
>> Line 4 Column 1 client\styles\core\__components.scss
Warning: Use --force to continue.
Aborted due to warnings.
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v5.10.1
npm ERR! npm v3.8.3
npm ERR! code ELIFECYCLE
npm ERR! web#12.5.6 dev: `grunt develop:quick`
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the web#12.5.6 dev script 'grunt develop:quick'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the web package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! grunt develop:quick
npm ERR! You can get information on how to open an issue for this project
with:
npm ERR! npm bugs web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls web
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\<User>\Documents\GitHub\web\npm-debug.log
PS C:\Users\<User>\Documents\GitHub\web>

sudo npm install gives me a access denied

I am using ionic and I have fetched my project through git from machine1 to machine2.
My ionic infos gives me this :
[ERROR] Error with ./node_modules/#ionic/app-scripts/package.json
file: FILE_NOT_FOUND
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
local packages:
#ionic/app-scripts : not installed
Ionic Framework : ionic-angular 3.7.1
System:
Node : v8.9.1
npm : 5.5.1
OS : macOS High Sierra
Misc:
backend : pro
When I run sudo npm install I get the following :
npm WARN checkPermissions Missing write access to
/Users/gerald/Documents/ionic/yesterdayweather/node_modules npm WARN
checkPermissions Missing write access to
/Users/gerald/Documents/ionic/yesterdayweather/node_modules/#ionic
And then
gyp ERR! configure error gyp ERR! stack Error: EACCES: permission
denied, mkdir
'/Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-sass/build'
gyp ERR! System Darwin 17.2.0 gyp ERR! command
"/usr/local/Cellar/node/8.9.1/bin/node"
"/Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-gyp/bin/nod
e-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags="
"--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd
/Users/gerald/Documents/ionic/yesterdayweather/node_modules/node-sass
gyp ERR! node -v v8.9.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok
Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR!
errno 1 npm ERR! node-sass#4.5.3 postinstall: node scripts/build.js
npm ERR! Exit status 1
I have tried the following solution 1 and 3.
Basically I think I had node installed in a pkg way, so I removed it and intalled it with brew, so actually I should not have this issue.
But I tried anyway option 1 and it still does not work.
Any idea ?
Thanks !
It looks like a script is trying to write files, which npm by default denies when running as root. You can put --unsafe-perm behind the command to disable this safeguard.
You also should not run npm install with sudo because it is not necessary. Only when using the -g flag for installing modules globally should you use sudo.
2019 EDIT: It goes without saying that disabling safe guards like this can be very dangerous because you're giving a script a free pass to do whatever it wants. It's best to never use sudo and npm together, even when installing modules globally. If you're running into access issues with npm look into using a version manager or changing npm's default directory.
You shouldn't use sudo npm install. Clean up your environment (see more in my answer here) and then run just npm install.

To build AppRTC server

there.
I have trouble to build https://github.com/webrtc/samples in win 8.1.
I am trying to install npm dependencies.
But there are some errors like as the following.
node.js version is v4.2.3 and npm version is v2.14.7
D:\_Temp\AppRTC\samples>npm install
> travis-multirunner#3.0.0 postinstall D:\_Temp\AppRTC\samples\node_modules\trav
is-multirunner
> ./bin/travis-sync
'.' is not recognized as an internal or external command,
operable program or batch file.
> chromedriver#2.20.0 install D:\_Temp\AppRTC\samples\node_modules\chromedriver
> node install.js
Downloading http://chromedriver.storage.googleapis.com/2.20/chromedriver_win32.z
ip
Saving to C:\Users\JIS\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Receiving...
Received 782K...
Received 1564K...
Received 2346K...
Received 2398K total.
Extracting zip contents
Copying to target path D:\_Temp\AppRTC\samples\node_modules\chromedriver\lib\chr
omedriver
Done. ChromeDriver binary available at D:\_Temp\AppRTC\samples\node_modules\chro
medriver\lib\chromedriver\chromedriver.exe
> utf-8-validate#1.2.1 install D:\_Temp\AppRTC\samples\node_modules\selenium-web
driver\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild
D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\node_modules\ws\node_mod
ules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\n
odejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gy
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
validation.cc
win_delay_load_hook.c
Creating library D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\n
ode_modules\ws\node_modules\utf-8-validate\build\Release\validation.lib and o
bject D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\node_modules\ws
\node_modules\utf-8-validate\build\Release\validation.exp
Generating code
Finished generating code
validation.vcxproj -> D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver
\node_modules\ws\node_modules\utf-8-validate\build\Release\\validation.node
> bufferutil#1.2.1 install D:\_Temp\AppRTC\samples\node_modules\selenium-webdriv
er\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\node_modules\ws\node_mod
ules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodej
s\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js
" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
bufferutil.cc
win_delay_load_hook.c
Creating library D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\n
ode_modules\ws\node_modules\bufferutil\build\Release\bufferutil.lib and objec
t D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver\node_modules\ws\nod
e_modules\bufferutil\build\Release\bufferutil.exp
Generating code
Finished generating code
bufferutil.vcxproj -> D:\_Temp\AppRTC\samples\node_modules\selenium-webdriver
\node_modules\ws\node_modules\bufferutil\build\Release\\bufferutil.node
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! travis-multirunner#3.0.0 postinstall: `./bin/travis-sync`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the travis-multirunner#3.0.0 postinstall script './bin/travis
-sync'.
npm ERR! This is most likely a problem with the travis-multirunner package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./bin/travis-sync
npm ERR! You can get their info via:
npm ERR! npm owner ls travis-multirunner
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\_Temp\AppRTC\samples\npm-debug.log
D:\_Temp\AppRTC\samples>node test/server.js
D:\_Temp\AppRTC\samples\test\server.js:18
key: keys.serviceKey,
^
TypeError: Cannot read property 'serviceKey' of undefined
at D:\_Temp\AppRTC\samples\test\server.js:18:14
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:246:24
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:150:24
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:71:20
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:951:20
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:930:13
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:829:20
at D:\_Temp\AppRTC\samples\node_modules\pem\lib\pem.js:999:20
at F (D:\_Temp\AppRTC\samples\node_modules\pem\node_modules\which\which.js:7
3:25)
at E (D:\_Temp\AppRTC\samples\node_modules\pem\node_modules\which\which.js:7
6:29)
Thanks for any reply.
It's quite easy to setup a virtual machine using Virtualbox.
In fact I did just that at home on my gaming pc, just installed latest Debian, node.js, Sublime in a Virtualbox VM, then I use Virtualbox seamless mode which just puts the Windows in the VM on top of the host OS desktop.
Works great!
travis-multirunner which is used for automatted testing is not supported on windows.

Error when installing log.io using npm

I am trying to install log.io following the instruction from https://github.com/NarrativeScience/Log.io. It suggests using npm install command.
npm install -g log.io
The error I am getting is like below. And I tried on both Mac OS and Ubuntu, both no luck. Can anyone help me?
> contextify#0.1.13 install /usr/local/lib/node_modules/log.io/node_modules/jquery/node_modules/contextify
> node-gyp rebuild
npm http GET https://registry.npmjs.org/cssstyle
npm http GET https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/cssstyle
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-32-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/log.io/node_modules/jquery/node_modules/contextify
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! Error: ENOENT, chown '/usr/local/lib/node_modules/log.io/node_modules/jquery/node_modules/jsdom/node_modules/request/README.md'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
...
Finally I found the problems.
Ubuntu
On Ubuntu 14.04, the default repository of apt-get for node is not nodejs itself, but ax25-node. This will generate a default command node in /usr/sbin/ and does nothing if you call node (which is called by npm during the installation). I removed this package and created a symlink between node and nodejs, finally solved the problem.
sudo apt-get autoremove node
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g log.io
Mac OS
The error log is quite different from what I got from Ubuntu. After some googling about node-gyp installation failure, I found this issue, which led me to install the Xcode dev tools. Not sure why this happens but it seems there are some conflicts between homebrew and Xcode. Anyway, it finally works :-)
This looks like a race condition in an older version of npm. There have been a lot of improvements to npm -- especially around conflicts and race conditions during install -- since 1.4. Can you try updating your npm installation?
To update npm on Windows, follow the instructions here: https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows
If you still see the problem after updating npm, could you please upload your npm-debug.log as a gist http://gist.github.com? If possible, run npm with at least one -d flag to increase the logging level.
Thanks!
i create this install package...
http://tinyurl.com/kfnfng6
1 - download it
2 - untar it (tar -xvf install_log.io.tar)
3 - cd install_log.io
4 - sh install.sh
5 - enjoy!
This form is simple and quiet.. i hope help other users... What i do? simple.. download packages and dependencies , and put all in one package and create a script...
;)

Resources