From 3e2f3900b83e67afc083180380c66a349f1e2e6b Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 20 Nov 2021 12:55:15 +0100 Subject: [PATCH 1/5] [fix] nvm.install: add missing popd / node.env exit with error (254) Issue:: $ make clean node.env ... CLEAN [NVM] drop .nvm/ ... INFO: install Node.js by NVM ... Now using node v16.13.0 (npm v8.1.0) ... INSTALL searx/static/themes/oscar/package.json npm ERR! code ENOENT npm ERR! syscall open # Here now comes the issue, caused by the missing 'popd' .. npm ERR! path SearXNG/.nvm/searx/static/themes/oscar/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open 'SearXNG/.nvm/searx/static/themes/oscar/package.json' ERROR: node.env exit with error (254) make: *** [Makefile:99: node.env] Error 254 Signed-off-by: Markus Heiser --- utils/lib_nvm.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/lib_nvm.sh b/utils/lib_nvm.sh index d35abef2a..77e9eabf5 100755 --- a/utils/lib_nvm.sh +++ b/utils/lib_nvm.sh @@ -115,6 +115,7 @@ nvm.install() { NVM_VERSION_TAG="$(git describe --abbrev=0 --tags --match "v[0-9]*" "${NVM_VERSION_TAG}")" info_msg "checkout ${NVM_VERSION_TAG}" git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} " + popd &> /dev/null nvm.env } @@ -133,7 +134,7 @@ nvm.clean() { fi } -nvm.status(){ +nvm.status() { if command -v node >/dev/null; then info_msg "Node.js is installed at $(command -v node)" info_msg "Node.js is version $(node --version)" @@ -157,7 +158,7 @@ nvm.status(){ fi } -nvm.nodejs(){ +nvm.nodejs() { nvm install --lts nvm.status } From 6b4cad768dff60e328163497f7660dfbe7d63ec2 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 20 Nov 2021 15:19:17 +0100 Subject: [PATCH 2/5] [mod] NVM: pin Node.js to v16.13.0 Signed-off-by: Markus Heiser --- .nvmrc | 1 + utils/lib_nvm.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..5dbac1ed0 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16.13.0 \ No newline at end of file diff --git a/utils/lib_nvm.sh b/utils/lib_nvm.sh index 77e9eabf5..486146312 100755 --- a/utils/lib_nvm.sh +++ b/utils/lib_nvm.sh @@ -154,12 +154,12 @@ nvm.status() { info_msg "NVM is installed at ${NVM_DIR}" else warn_msg "NVM is not installed" - info_msg "to install NVM and Node.js (LTS) use: ${main_cmd} nvm install --lts" + info_msg "to install NVM and Node.js (LTS) use: ${main_cmd} nvm.nodejs" fi } nvm.nodejs() { - nvm install --lts + nvm install nvm.status } From 61af1478494fb748f7f55c6e2253a7a35d663cd1 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 20 Nov 2021 15:21:35 +0100 Subject: [PATCH 3/5] [emacs] use NVM environment installed at nvm-dir /.nvm Signed-off-by: Markus Heiser --- .dir-locals.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.dir-locals.el b/.dir-locals.el index b8f7ecc76..e1d0b8ef7 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -19,6 +19,7 @@ ;; Some buffer locals are referencing the project environment: ;; ;; - prj-root --> / +;; - nvm-dir --> /.nvm ;; - python-environment-directory --> /local ;; - python-environment-default-root-name --> py3 ;; - python-shell-virtualenv-root --> /local/py3 @@ -57,6 +58,9 @@ (setq-local python-environment-directory (expand-file-name "./local" prj-root)) + ;; to get in use of NVM enviroment, install https://github.com/rejeep/nvm.el + (setq-local nvm-dir (expand-file-name "./.nvm" prj-root)) + ;; use 'py3' enviroment as default (setq-local python-environment-default-root-name "py3") @@ -90,6 +94,8 @@ (js-mode . ((eval . (progn + ;; flycheck should use the (local) NVM environment (see nvm-dir) + (nvm-use-for-buffer) (setq-local js-indent-level 2) ;; flycheck should use the eslint checker from simple theme (setq-local flycheck-javascript-eslint-executable From 69dd025da904e5f067e234d9b65d1a8a3ea8fdab Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 20 Nov 2021 15:40:18 +0100 Subject: [PATCH 4/5] [mod] nvm.cmd ... : run command ... in NVM environment Signed-off-by: Markus Heiser --- utils/lib_nvm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/lib_nvm.sh b/utils/lib_nvm.sh index 486146312..cd2fbc189 100755 --- a/utils/lib_nvm.sh +++ b/utils/lib_nvm.sh @@ -94,6 +94,7 @@ nvm.: use nvm (without dot) to execute nvm commands directly clean : remove NVM installation status : prompt some status informations about nvm & node nodejs : install Node.js latest LTS + cmd ... : run command ... in NVM environment bash : start bash interpreter with NVM environment sourced EOF } @@ -168,6 +169,11 @@ nvm.bash() { bash --init-file <(cat "${NVM_DIR}/nvm.sh" "${NVM_DIR}/bash_completion") } +nvm.cmd() { + nvm.ensure + "$@" +} + nvm.ensure() { if ! nvm.is_installed; then nvm.install From 5242a841a5dd2179d1ed620a67594932eb129422 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 20 Nov 2021 17:00:07 +0100 Subject: [PATCH 5/5] [mod] NVM: dev-tools pre-installed in NVM's node installation The Node.js installation in the NVM environment can be used by IDEs and other developer tasks. The required developer packagaes are added to the file ./.nvm_packages and will be installed when Node.js is installed. Initial we start with: - eslint Having a dedicated developer enviroment, provided by nvm makes it easy to integrate Node.js packages into various IDEs. One example is shown in the .dir-locals.el which is used by emacs. [1] https://github.com/nvm-sh/nvm#default-global-packages-from-file-while-installing [2] https://eslint.org Signed-off-by: Markus Heiser --- .dir-locals.el | 5 +---- .nvm_packages | 8 ++++++++ utils/lib_nvm.sh | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .nvm_packages diff --git a/.dir-locals.el b/.dir-locals.el index e1d0b8ef7..f67ab4714 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -94,12 +94,9 @@ (js-mode . ((eval . (progn - ;; flycheck should use the (local) NVM environment (see nvm-dir) + ;; use nodejs from the (local) NVM environment (see nvm-dir) (nvm-use-for-buffer) (setq-local js-indent-level 2) - ;; flycheck should use the eslint checker from simple theme - (setq-local flycheck-javascript-eslint-executable - (expand-file-name "searx/static/themes/simple/node_modules/.bin/eslint" prj-root)) (flycheck-mode) )))) diff --git a/.nvm_packages b/.nvm_packages new file mode 100644 index 000000000..13eabc5c2 --- /dev/null +++ b/.nvm_packages @@ -0,0 +1,8 @@ +# -*- coding: utf-8; mode: conf-unix -*- +# +# Developement tools pre-installed in NVM's node installation [1] +# +# [1] https://github.com/nvm-sh/nvm#default-global-packages-from-file-while-installing + +eslint + diff --git a/utils/lib_nvm.sh b/utils/lib_nvm.sh index cd2fbc189..267ba8a4a 100755 --- a/utils/lib_nvm.sh +++ b/utils/lib_nvm.sh @@ -117,6 +117,7 @@ nvm.install() { info_msg "checkout ${NVM_VERSION_TAG}" git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} " popd &> /dev/null + cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages" nvm.env }