Sing's Log

Knowledge worth sharing


  • Home

  • Tags

  • Timeline

  • Portfolio

  • Search

node-gyp rebuild contextify error

Posted on 2018-03-29 | Edited on 2025-08-03 |

TL;DR

  1. yarn why contextify
  2. Remove/Update the result dependency from step 1. by modify package.json.
  3. npm install

Full scenario

Today I encounter an error when npm install, the error look like this :

1
2
3
4
error M:\Github\asing1001.github.io\node_modules\contextify: Command failed.
...
...
..\src\contextify.cc(150): error C2039: 'SetAccessCheckCallbacks': is not a member of 'v8::ObjectTemplate'

This is caused by the package contextify too old, to find out which package dependent on contextify, I use yarn why contextify in command prompt :

1
2
3
4
5
6
7
8
M:\Github\asing1001.github.io> yarn why contextify
yarn why v0.22.0
[1/4] Why do we have the module "contextify"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "hexo-migrator-blogger#to-markdown#jsdom" depends on it.
Done in 2.30s.

Obviously it is refenrence by dependency hexo-migrator-blogger, I update package.json to remove this package and npm install again, it is fixed :)

Install Gitlab CI runner on windows

Posted on 2018-03-26 | Edited on 2025-08-03 |

Before start

To enable Gitlab-CI, you need to install runners, it is an external service to help build your project. Make sure network between Gitlab server and runner is accessible.

Install

  1. Download gitlab-runner.exe to a folder, ex:C:\GitLab-Runner
  2. Run Command prompt(Administrator):

    1
    gitlab-runner.exe register
  3. Enter URL and token from Project > settings > CI/CD > Runners settings, choose executor as shell.

  4. After register succeed, run

    1
    2
    gitlab-runner install
    gitlab-runner start
  5. Go to Project > settings > CI/CD > Runners settings again, you should find your runner here

  6. Start using the runner by creating first .gitlab-ci.yml in your project root folder

Update

  1. Stop service:

    1
    2
    cd C:\GitLab-Runner
    gitlab-runner stop
  2. Download the newest binary and replace current gitlab-runner.exe.

  3. Start service:

    1
    gitlab-runner start

Uninstall

Command prompt (Administrator):

1
2
3
4
5
cd C:\GitLab-Runner
gitlab-runner stop
gitlab-runner uninstall
cd ..
rmdir /s GitLab-Runner

Reference

https://docs.gitlab.com/runner/

Python - handle package dependencies with requirements.txt

Posted on 2018-03-18 | Edited on 2025-08-03 |

To create same environment in python, you must know requirements.txt, it includes packages dependencies and let you install by a single command, a requirements.txt looks like this :

1
2
3
beautifulsoup4==4.6.0
certifi==2018.1.18
chardet==3.0.4

To generate requirements.txt

1
2
3
4
5
6
# Without using virtual environment
pip install pipreqs
pipreqs /path/to/project

# With virtual environment
pip freeze > requirements.txt

Install packages from requirements.txt :

1
pip install -r requirements.txt

pip install bypass SSL certificate :

1
2
3
4
pip install --trusted-host pypi.python.org <package_name>

# Combine with requirements.txt
pip install --trusted-host pypi.python.org -r requirements.txt

Reference

https://github.com/bndr/pipreqs
pip install --help is your friend.

Copy / Backup MongoDB

Posted on 2018-03-10 | Edited on 2025-08-03 |

Directly copy db from ip :

1
2
3
mongo <ip>
use admin
db.runCommand({copydb:1, fromdb:"<DB Name>", todb:"<DB Name>", fromhost:"<DB HOST IP>"})

Export / Restore DB

1
2
3
4
5
6
# Export
mongodump --db <dbname>

# Restore
mongorestore --port <port number> <path to backup folder>
# e.g. mongorestore --port 27017 X:\dump

Note :

  1. Run commands in administrator mode
  2. If commands not found, excute commands under mongodb bin folder, windows default path : C:\Program Files\MongoDB\Server\3.2\bin\

Reference :

https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/

Markdown to Word with pandoc

Posted on 2018-02-13 | Edited on 2025-08-03 |

To convert Markdown into Word format, pandoc is the best tool I found.

  • Step1 : Install pandoc
  • Step2 : pandoc myfile.md -o myfile.docx

Chromebook shortcut

Posted on 2018-02-10 | Edited on 2025-08-03 |
  • ctrl + alt + / : Show Keyboard Shortcut
  • ctrl + 口|| : Screenshot
  • ctrl + shift + 口|| : Screenshot region
  • ctrl + shift + i : Open developer tools
  • alt + search : Toggle Caps Lock
  • alt + shift + m : Open file manager
  • ctrl + space : Change input method
  • shift + esc : Open task manager
  • ctrl + alt + t : Open terminal
  • search + button between esc and power : F1~F10

Online IDE - AWS Cloud9 introduction

Posted on 2018-02-09 | Edited on 2025-08-03 |

Recently I found that AWS Cloud9 is so good that help me coding in my chromebook.
Here I want to share how I use it with my nodejs project, it is free, fast and easy.

  1. Go to https://aws.amazon.com/tw/cloud9/
  2. Click Create environment and choose your preference
  3. Wait seconds to see your cloud9 IDE
  4. To switch keyboard setting, go to Edit > Keyboard mode > Sublime Vim Emac
  5. Setup nodejs developement environment via terminal

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    # Clone repo 
    git clone repo

    # Switch node version
    nvm install --lts

    # Use new version
    nvm use stable

    # Install yarn
    sudo npm install -g yarn

    # Install package
    yarn

    # Start application
    npm start
  6. To browse application webpage, go to Preview > Preview Running Application

Linux commands cheatsheet

Posted on 2018-02-08 | Edited on 2025-08-03 |

Always use man commandName to know what the command is before copy and paste.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Open a new shell with root, exit with "exit" or "ctrl+d"
sudo su -

# Show how to use a command
man command

# Find first excutable path
whichis command

# Find every excutable path
whereis command

# Use proxy
export http_proxy=http://server-ip:port/
export https_proxy=http://server-ip:port/

# Check CentOS version
rpm --query centos-release

# Read file
cat filename

# Write file (after excute, type content and ctrl+d to save)
cat > filename

# RPM install
rpm -ivh file.rpm

# switch to last directory
cd -

# Download file with wget -c=continue download
wget -c --header "Cookie: foo=bar" http://url/to/file`

# Force reboot immediately
reboot -f

# Rename files
rename <old name> <new name> <Regex match>

# Connect to openvpn
sudo openvpn --config client.ovpn

# List port listening
lsof -i :<port>

# kill process by id
kill PID

# List recent command history
history

# excute command from history
!<search text>
!vi # excute recent command contains vi

Visual Studio NPM Task Runner

Posted on 2017-10-30 | Edited on 2025-08-03 |

Recently my co-worker recommends a great VS extension NPM task runner. Instead of running NPM task via a separate terminal, it will discover NPM task via package.json and run them inside Visual Studio by a double-click.

Install via Tools > Extensions and Updates > Online > Search NPM task runner

Task Runner Explorer locate in View > Other Windows > Task Runner Explorer
Run task by double-click tasks in sidebar, close it by x button

If your task fails, it probably references to wrong NPM or Node.js, to fix it change the order in Tools > Options > Projects and Solutions > External Web Tools. I lift-up ${PATH} to the second one.

Install public npm package with ProGet npm connector

Posted on 2017-09-27 | Edited on 2025-08-03 |

For security reason, private CI server may not have internet access. Instead, it connect to private registry like ProGet. To install public npm package, ProGet connector is here to help, steps as following :

  1. Go to Connectors => create connectors => Feed type:npm => Save
  2. Go to feeds => Create New Feed => Feed type:npm => Feed name:npm
  3. Feed Connectors => add connector => registry.npmjs.org
  4. Set up npm via command line in server
    npm config set registry http://{progethost}/npm/npm

Now try npm install, it should work as it connect to public npm registry.

Reference : http://inedo.com/support/documentation/proget/feed-types/npm

1…567…9
Sing Ming Chen

Sing Ming Chen

Sing's log, a developer's blog

90 posts
259 tags
GitHub E-Mail Linkedin
© 2025 Sing Ming Chen
Powered by Hexo v3.9.0
|
Theme — NexT.Gemini v6.3.0