This issue started to happen today, when running on Circle.CI. When running locally, everything works as expected.
Description
NPN command not found
Steps to reproduce the issue:
fin bashnpmDescribe the results you received:
See error bash: npm: command not found
Describe the results you expected:
NPM command should be executed.
Output of fin config:
fin config output
WARNING: No swap limit support
---------------------
COMPOSE_PROJECT_NAME_SAFE: guwordpress
COMPOSE_FILE:
/home/circleci/.docksal/stacks/volumes-bind.yml
/home/circleci/.docksal/stacks/stack-default.yml
/home/circleci/guwordpress/.docksal/docksal.yml
ENV_FILE:
/home/circleci/guwordpress/.docksal/docksal.env
PROJECT_ROOT: /home/circleci/guwordpress
DOCROOT: docroot
VIRTUAL_HOST: guwordpress.docksal
VIRTUAL_HOST_ALIASES: *.guwordpress.docksal
IP: 192.168.64.100
MYSQL: 192.168.64.100:32768
Docker Compose configuration
---------------------
services:
browser:
dns:
- 192.168.64.100
- 8.8.8.8
- 192.168.64.100
- 8.8.8.8
hostname: browser
image: selenium/standalone-chrome
cli:
dns:
- 192.168.64.100
- 8.8.8.8
environment:
BLACKFIRE_CLIENT_ID: null
BLACKFIRE_CLIENT_TOKEN: null
DOCROOT: docroot
HOST_GID: '1002'
HOST_UID: '1001'
SECRET_ACAPI_EMAIL: null
SECRET_ACAPI_KEY: null
SECRET_SSH_PRIVATE_KEY: null
SECRET_TERMINUS_TOKEN: null
VIRTUAL_HOST: guwordpress.docksal
XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
XDEBUG_ENABLED: '0'
hostname: cli
image: docksal/cli:edge-php7.2
volumes:
- docksal_ssh_agent:/.ssh-agent:ro
- /home/docker
- project_root:/var/www:rw,nocopy
db:
dns:
- 192.168.64.100
- 8.8.8.8
environment:
MYSQL_DATABASE: default
MYSQL_PASSWORD: user
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: user
hostname: db
image: docksal/db:1.1-mysql-5.6
ports:
- 0:3306/tcp
volumes:
- project_root:/var/www:ro,nocopy
web:
depends_on:
cli:
condition: service_started
dns:
- 192.168.64.100
- 8.8.8.8
environment:
APACHE_BASIC_AUTH_PASS: null
APACHE_BASIC_AUTH_USER: null
APACHE_DOCUMENTROOT: /var/www/docroot
hostname: web
image: docksal/web:edge-apache2.4
labels:
io.docksal.project-root: /home/circleci/guwordpress
io.docksal.virtual-host: guwordpress.docksal,*.guwordpress.docksal,guwordpress.docksal.*
volumes:
- project_root:/var/www:ro,nocopy
version: '2.1'
volumes:
docksal_ssh_agent:
external: true
name: docksal_ssh_agent
project_root:
driver: local
driver_opts:
device: /home/circleci/guwordpress
o: bind
type: none
---------------------
Output of fin sysinfo:
fin sysinfo output
```
WARNING: No swap limit support
βββ OS
Linux Ubuntu 14.04
Linux default-613e5940-f618-4a19-8d5b-a0d4446b46b8 4.4.0-96-generic #119~14.04.1-Ubuntu SMP Wed Sep 13 08:40:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Mode: Linux Kernel
βββ FIN
fin version: 1.60.2
βββ ENVIRONMENT
DOCKER_HOST |
WARNING: Non-default DOCKER_HOST
βββ DOCKER
EXPECTED VERSION: 18.03.1-ce
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:18:46 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:16:59 2018
OS/Arch: linux/amd64
Experimental: false
βββ DOCKER INFO
Containers: 7
Running: 7
Paused: 0
Stopped: 0
Images: 7
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
Kernel Version: 4.4.0-96-generic
Operating System: Ubuntu 14.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.305GiB
Name: default-613e5940-f618-4a19-8d5b-a0d4446b46b8
ID: H4I5:ZTAM:GNQK:AM3G:HF4X:RFAK:U67G:GHDB:L4S3:EBKB:Y7Z2:QPXP
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
βββ DOCKER COMPOSE
EXPECTED VERSION: 1.21.1
docker-compose version 1.21.1, build 5a3f1a3
docker-py version: 3.3.0
CPython version: 3.6.5
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
WARNING: No swap limit support
βββ DOCKER: IMAGES
REPOSITORY TAG IMAGE ID CREATED SIZE
docksal/cli edge-php7.2 ab83fe201d04 2 days ago 850MB
selenium/standalone-chrome latest 251941c07ece 6 days ago 878MB
docksal/vhost-proxy 1.2 a1c980537985 4 months ago 166MB
docksal/web edge-apache2.4 1b939e80c6f3 10 months ago 87.5MB
docksal/db 1.1-mysql-5.6 6feb79af9597 11 months ago 298MB
docksal/dns 1.0 20c7a535479d 18 months ago 61.6MB
docksal/ssh-agent 1.0 148220cc033d 18 months ago 12.2MB
βββ DOCKER: CONTAINERS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f931d1dc293c docksal/web:edge-apache2.4 "httpd-foreground" 17 minutes ago Up 17 minutes 80/tcp, 443/tcp guwordpress_web_1
9babc8c6f141 docksal/cli:edge-php7.2 "/opt/startup.sh supβ¦" 17 minutes ago Up 17 minutes (healthy) 22/tcp, 3000/tcp, 9000/tcp guwordpress_cli_1
f5f249e0bac6 docksal/db:1.1-mysql-5.6 "/entrypoint.sh mysqβ¦" 17 minutes ago Up 17 minutes 0.0.0.0:32768->3306/tcp guwordpress_db_1
69bf11219a78 selenium/standalone-chrome "/opt/bin/entry_poinβ¦" 17 minutes ago Up 17 minutes 4444/tcp guwordpress_browser_1
3311d6e287c0 docksal/ssh-agent:1.0 "/run.sh ssh-agent" 20 minutes ago Up 20 minutes docksal-ssh-agent
db2fa7498b57 docksal/dns:1.0 "/opt/entrypoint.sh β¦" 20 minutes ago Up 20 minutes 192.168.64.100:53->53/udp docksal-dns
343725c191f3 docksal/vhost-proxy:1.2 "docker-entrypoint.sβ¦" 20 minutes ago Up 20 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp docksal-vhost-proxy
βββ HDD Usage
Filesystem Size Used Avail Use% Mounted on
udev 3.7G 4.0K 3.7G 1% /dev
tmpfs 748M 456K 748M 1% /run
/dev/sda1 99G 8.0G 87G 9% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 3.7G 0 3.7G 0% /run/shm
none 100M 0 100M 0% /run/user
βββ RAM Usage
total used free shared buffers cached
Mem: 7659332 5126276 2533056 3228 165004 3716196
-/+ buffers/cache: 1245076 6414256
Swap: 0 0 0
βββ RAM Usage per container
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
f931d1dc293c guwordpress_web_1 0.07% 2.426MiB / 7.305GiB 0.03% 830B / 0B 0B / 0B 82
9babc8c6f141 guwordpress_cli_1 0.02% 27.02MiB / 7.305GiB 0.36% 56.2MB / 464kB 0B / 17.6MB 6
f5f249e0bac6 guwordpress_db_1 0.04% 482.6MiB / 7.305GiB 6.45% 1.34kB / 0B 0B / 223MB 21
69bf11219a78 guwordpress_browser_1 0.06% 63.38MiB / 7.305GiB 0.85% 1.25kB / 0B 0B / 0B 25
3311d6e287c0 docksal-ssh-agent 0.00% 656KiB / 7.305GiB 0.01% 802B / 0B 0B / 0B 2
db2fa7498b57 docksal-dns 0.16% 15.59MiB / 7.305GiB 0.21% 86.5kB / 116kB 0B / 0B 10
343725c191f3 docksal-vhost-proxy 0.11% 18.13MiB / 7.305GiB 0.24% 3.44kB / 0B 0B / 8.19kB 12
```
Installation log
Installation log
```
Build-agent version 0.0.7400-c4f46116 (2018-07-12T18:30:48+0000)
Creating a dedicated VM with default image
Assigned VM request id: 18884566
provisioning: ...VM 'default-613e5940-f618-4a19-8d5b-a0d4446b46b8' has been created
Initializing agent
Using build environment variables:
BASH_ENV=/tmp/.bash_env-5b4cbdb1d74000001370d183-0-build
CI=true
CIRCLECI=true
CIRCLE_BRANCH=18or-js
CIRCLE_BUILD_NUM=1123
CIRCLE_BUILD_URL=https://circleci.com/gh/georgetown-university/guwordpress/1123
CIRCLE_COMPARE_URL=https://github.com/georgetown-university/guwordpress/compare/18or-js
CIRCLE_JOB=build
CIRCLE_NODE_INDEX=0
CIRCLE_NODE_TOTAL=1
CIRCLE_PREVIOUS_BUILD_NUM=1115
CIRCLE_PROJECT_REPONAME=guwordpress
CIRCLE_PROJECT_USERNAME=georgetown-university
[email protected]:georgetown-university/guwordpress.git
CIRCLE_SHA1=01293f4eb5099399a0daeee3a3d061b92e90959b
CIRCLE_SHELL_ENV=/tmp/.bash_env-5b4cbdb1d74000001370d183-0-build
CIRCLE_STAGE=build
CIRCLE_USERNAME=dealancer
CIRCLE_WORKING_DIRECTORY=~/guwordpress
fin rebuild-code-site
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
WARNING: No swap limit support
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
WARNING: No swap limit support
^@^@Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
1/60: https://codeload.github.com/Ocramius/PackageVersions/legacy.zip/ad8a245decad4897cc6b432743913dad0d69753c
2/60: https://codeload.github.com/tkotosz/behat-extension-driver-locator/legacy.zip/af9fb11f5f3cc220ee2c08071ee9d50f11048b86
3/60: https://codeload.github.com/zendframework/zend-eventmanager/legacy.zip/a5e2583a211f73604691586b8406ff7296a946dd
4/60: https://codeload.github.com/elvetemedve/behat-screenshot/legacy.zip/04c63883147415e55dce85fc0bdd03383f906f59
5/60: https://codeload.github.com/container-interop/container-interop/legacy.zip/79cbf1341c22ec75643d841642dd5d6acd83bdb8
6/60: https://codeload.github.com/sensiolabs/BehatPageObjectExtension/legacy.zip/bd2a34221ba65ea8c86d8e693992d718de03dbae
7/60: https://codeload.github.com/Behat/MinkExtension/legacy.zip/80f7849ba53867181b7e412df9210e12fba50177
8/60: https://codeload.github.com/zendframework/zend-code/legacy.zip/2899c17f83a7207f2d7f53ec2f421204d3beea27
9/60: https://codeload.github.com/php-fig/container/legacy.zip/b7ce3b176482dbbc1245ebf52b181af44c2cf55f
10/60: https://codeload.github.com/symfony/event-dispatcher/legacy.zip/2391ed210a239868e7256eb6921b1bd83f3087b5
11/60: https://codeload.github.com/paulgibbs/behat-wordpress-extension/legacy.zip/2e9b91ed581914ff7106b6b3243b2ff1f8593f4d
12/60: https://codeload.github.com/Ocramius/ProxyManager/legacy.zip/a55d08229f4f614bf335759ed0cf63378feeb2e6
13/60: https://codeload.github.com/symfony/class-loader/legacy.zip/e63c12699822bb3b667e7216ba07fbcc3a3e203e
14/60: https://codeload.github.com/symfony/config/legacy.zip/5ceefc256caecc3e25147c4e5b933de71d0020c4
15/60: https://codeload.github.com/Behat/Behat/legacy.zip/d60b161bff1b95ec4bb80bb8cb210ccf890314c2
16/60: https://codeload.github.com/symfony/filesystem/legacy.zip/562bf7005b55fd80d26b582d28e3e10f2dd5ae9c
17/60: https://codeload.github.com/symfony/finder/legacy.zip/087e2ee0d74464a4c6baac4e90417db7477dc238
18/60: https://codeload.github.com/symfony/dependency-injection/legacy.zip/f2a3f0dc640a28b8aedd51b47ad6e6c5cebb3c00
19/60: https://codeload.github.com/Behat/Transliterator/legacy.zip/826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c
20/60: https://codeload.github.com/symfony/translation/legacy.zip/16328f5b217cebc8dd4adfe4aeeaa8c377581f5a
21/60: https://codeload.github.com/symfony/console/legacy.zip/2d5d973bf9933d46802b01010bd25c800c87c242
22/60: https://codeload.github.com/instaclick/php-webdriver/legacy.zip/6fa959452e774dcaed543faad3a9d1a37d803327
23/60: https://codeload.github.com/minkphp/MinkSelenium2Driver/legacy.zip/473a9f3ebe0c134ee1e623ce8a9c852832020288
24/60: https://codeload.github.com/symfony/yaml/legacy.zip/80e4bfa9685fc4a09acc4a857ec16974a9cd944e
25/60: https://codeload.github.com/guzzle/guzzle/legacy.zip/407b0cb880ace85c9b63c5f9551db498cb2d50ba
26/60: https://codeload.github.com/guzzle/promises/legacy.zip/a59da6cf61d80060647ff4d3eb2c03a2bc694646
27/60: https://codeload.github.com/guzzle/psr7/legacy.zip/f5b8a8512e2b58b0071a7280e39f14f72e05d87c
28/60: https://codeload.github.com/minkphp/MinkGoutteDriver/legacy.zip/8b9ad6d2d95bc70b840d15323365f52fcdaea6ca
29/60: https://codeload.github.com/minkphp/Mink/legacy.zip/e6930b9c74693dff7f4e58577e1b1743399f3ff9
30/60: https://codeload.github.com/symfony/polyfill-ctype/legacy.zip/7cc359f1b7b80fc25ed7796be7d96adc9b354bae
31/60: https://codeload.github.com/minkphp/MinkBrowserKitDriver/legacy.zip/1b9a7ce903cfdaaec5fb32bfdbb26118343662eb
32/60: https://codeload.github.com/FriendsOfPHP/Goutte/legacy.zip/395f61d7c2e15a813839769553a4de16fa3b3c96
33/60: https://codeload.github.com/php-fig/http-message/legacy.zip/f6561bf28d520154e4b0ec72be95418abe6d9363
34/60: https://codeload.github.com/symfony/browser-kit/legacy.zip/16355a5d0f1499c77efee5ff68d8ea61624d4da1
35/60: https://codeload.github.com/symfony/css-selector/legacy.zip/d2ce52290b648ae33b5301d09bc14ee378612914
36/60: https://codeload.github.com/symfony/dom-crawler/legacy.zip/3350cacf151b48d903114ab8f7a4ccb23e07e10a
37/60: https://codeload.github.com/Behat/Gherkin/legacy.zip/74ac03d52c5e23ad8abd5c5cce4ab0e8dc1b530a
38/60: https://downloads.wordpress.org/plugin/wp-redis.0.7.0.zip
39/60: https://downloads.wordpress.org/plugin/pantheon-hud.0.1.2.zip
40/60: https://downloads.wordpress.org/plugin/wp-native-php-sessions.0.6.9.zip
41/60: https://downloads.wordpress.org/plugin/wp-cfm.zip
42/60: https://downloads.wordpress.org/plugin/tinymce-advanced.4.7.11.zip
43/60: https://downloads.wordpress.org/plugin/restricted-site-access.6.2.1.zip
44/60: https://downloads.wordpress.org/plugin/pantheon-advanced-page-cache.0.3.0.zip
45/60: https://downloads.wordpress.org/plugin/wp-saml-auth.0.3.9.zip
46/60: https://downloads.wordpress.org/plugin/duracelltomi-google-tag-manager.1.8.1.zip
47/60: https://downloads.wordpress.org/plugin/meta-box.4.19.10.zip
48/60: https://downloads.wordpress.org/plugin/wp-all-import.3.4.9.zip
49/60: https://downloads.wordpress.org/plugin/absolute-relative-urls.1.5.6.zip
50/60: https://codeload.github.com/symfony/polyfill-mbstring/legacy.zip/3296adf6a6454a050679cde90f95350ad604b171
51/60: https://downloads.wordpress.org/plugin/feedzy-rss-feeds.3.2.10.zip
52/60: https://downloads.wordpress.org/plugin/members.2.1.0.zip
53/60: https://codeload.github.com/composer/installers/legacy.zip/049797d727261bf27f2690430d935067710049c2
54/60: https://downloads.wordpress.org/plugin/gutenberg.3.0.1.zip
55/60: https://downloads.wordpress.org/plugin/wordpress-seo.7.6.1.zip
56/60: https://downloads.wordpress.org/plugin/better-wp-security.6.9.2.zip
57/60: https://codeload.github.com/johnpbloch/wordpress-core-installer/legacy.zip/a04c2c383ef13aae077f36799ed2eafdebd618d2
58/60: https://codeload.github.com/twigphp/Twig/legacy.zip/7b604c89da162034bdf4bb66310f358d313dd16d
59/60: https://codeload.github.com/cweagans/composer-patches/legacy.zip/2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3
60/60: https://github.com/pantheon-systems/WordPress/archive/4.9.7.zip
Finished: success: 60, skipped: 0, failure: 0, total: 60
Package operations: 60 installs, 0 updates, 0 removals
./.bundler@dealancer can you confirm this project is using docksal/cli:edge-php7.2 both locally and in CI?
Please also provide the output of the following on local:
fin docker image ls | grep docksal/cli
There was a change last week to the docksal/cli images, which switched NodeJS from a global installation back to a user level one (docksal/service-cli/#51).
Global installation mode was present in the edge versions from May 31st (https://github.com/docksal/service-cli/commit/567082a42510fea936104d7078981be2d6b54288) to July 13th (https://github.com/docksal/service-cli/commit/82a82581ddc2c667a45f2a76b1fe130e2636de56).
@lmakarov now I am able to reproduce issue locally, probably after I updated Docksal.
here is result of the output:
fin docker image ls | grep docksal/cli
docksal/cli edge-php7.2 ab83fe201d04 2 days ago 850MB
docksal/cli php7.2 7c0c3a119c9d 6 weeks ago 880MB
docksal/cli <none> a21a24bcb6ff 2 months ago 879MB
docksal/cli 2.1-php7.1 4c7331d4cf77 3 months ago 950MB
docksal/cli <none> b1ca4fa0852d 3 months ago 876MB
docksal/cli 2.0-php7.2 8f42648197b3 4 months ago 842MB
docksal/cli 1.3-php7 19bdddfeab89 9 months ago 759MB
Also when running fin config | grep docksal/cli both on Circle.CI and locally I can see:
image: docksal/cli:edge-php7.2
If NPM now is on the user level, what is the best way to run it? Is it documented somewhere?
@lmakarov do you mean NPM should be installed locally in the directory? Is there a way to install it globally without need to use different image?
And thanks for providing more information!
@dealancer node/npm are installed with nvm in /home/docker/.nvm/versions/node/v8.11.3/bin/node (current version in edge images).
Can you share the script code or relevant pieces from you rebuild-code-site-cli custom command?
When did you first start using it with npm? I have a feeling that it worked only while the edge images had node installed globally.
In the development version of Docksal, fin has some necessary adjustments to the way commands are executed in order to have npm stuff loaded inside cli correctly. I'll skip the long explanation for now.
You can try switching to the dev version of Docksal and see if that helps:
DOCKSAL_VERSION=develop fin update
Alternatively, try adding the following at the beginning of your custom command:
# Initialize the docker user environment inside cli
. $HOME/.profile
The last one should only be necessary until the upcoming 1.10.0 release of Docksal. It loads the user environment and nvm, so node/nmp become available.
@lmakarov we have started to use it long time ago, probably 4-5 months ago, but it was working fine until 2 days ago (even on the clean installation of Docksal). rebuild-code-site-cli just runs npm install.
Also I found a workaround to install a specific version of NPM, here is a command for that:
#!/usr/bin/env bash
#: exec_target = cli
## Install NPM globally
##
## Usage: fin install-npm-cli
# Abort if anything fails
set -e
echo "Check if NPM is installed...";
if [[ ! $(command -v npm) ]]; then
echo "Installing NPM...";
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
@dealancer the fin install-npm-cli command above installs NodeJS (and npm) globally. So yeah, that would explain why npm used to work for you, but does not explain why it stopped.
Can you please try my suggestions above?
@lmakarov no-no, fin install-npm-cli is a new command I introduce today to fix a problem (quick and dirty workaround).
rebuild-code-site-cli (a command that caused an error) is actually doing this:
#!/usr/bin/env bash
#: exec_target = cli
## Run composer install for a single site
##
## Usage: fin rebuild-code-site-cli
# Abort if anything fails
set -e
#-------------------------- Execution --------------------------------
cd ${PROJECT_ROOT}
composer install -d ${PROJECT_ROOT}
cd ${PROJECT_ROOT}/private/simplesamlphp/
composer install -d ${PROJECT_ROOT}/private/simplesamlphp/ --no-dev
cd ${PROJECT_ROOT}
bundle install
cd ${PROJECT_ROOT}/custom/themes/whitehaven-nu/
npm install
cd ${PROJECT_ROOT}/custom/themes/whitehaven-nu/
./gulp.sh build
#-------------------------- END: Execution --------------------------------
I think we can close this issue now.
@dealancer install-npm-cli is a workaround and should not be necessary, assuming node/npm load correctly inside cli. I'll like to make sure that that is the case before this issue is closed, since others may run into the same problem.
@dealancer BTW is there a reason you are using the edge image version of cli?
If you remove this override and stick to the current default version for cli (v2.2), then you will not have issues with node/npm not being loaded.
In the upcoming release we will switch the default cli image to v2.3, along with the necessary adjustment in fin to work correctly with this version of cli.
@lmakarov re image, I not sure how I ended up using the edge image. Probably, I was trying to use recent npm version with audit command there.
Thanks for advise and updates about new release.
@dealancer so which approach did you end up going with? Did you switch to the stable 2.2 cli version?
Regarding npm audit - this looks to be available in npm 6.0.0+.
From the NodeJS download page:
Latest LTS Version: 8.11.3 (includes npm 5.6.0)
Latest Current Version: 10.7.0 (includes npm 6.1.0)
We are sticking with LTS releases in cli, which means no npm audit command yet. To get that one, you will have to either manually update npm (npm install -g npm) or switch to a newer node version (e.g. nvm install node 10.7.0) as part of you project init process.
I'm having the same issue with CLI_IMAGE='docksal/cli:2.3-php7.2'. This was triggered by the edge version and now is in the cli:2.3 version. I couldn't figure out how to use npm/nvm/node in my custom script. So I added this to install it for now:
# Install Node
fin exec 'curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -'
fin exec 'sudo apt-get install -y nodejs'
FYI, I could use nvm inside of fin bash, but I first had to run . $HOME/.profile. I couldn't get it to work in my custom command.
@lmakarov I am getting npm not found issue even when using docksal/cli:2.2-php7.2. I am still figuring out the best solution.
@chrisroane, @dealancer have you tried this?
Alternatively, try adding the following at the beginning of your custom command:
# Initialize the docker user environment inside cli . $HOME/.profileThe last one should only be necessary until the upcoming 1.10.0 release of Docksal. It loads the user environment and nvm, so node/nmp become available.
This assumes your custom commands are executed inside cli (#: exec_target = cli).
I tried fin exec '. $HOME/.profile' and that didn't seem to work. Here is my full init command. This does work when I fin bash and run that command, but it wasn't working here.
I think the problem is this command isn't running with #: exec_target = cli
#!/bin/bash
## Sets up node dependencies, runs the build and downloads db + user files.
##
## Usage: fin init (build + db + user files)
## Usage (build + db only): fin init db
## Usage (build + user files only): fin init files
## Usage (build only): fin init no-data
##
DATA=$1
DB="false"
FILES="false"
# Should we download database?
if [ "$DATA" == "" ] || [ "$DATA" == "db" ]; then
DB="true"
fi
# Should we download user files?
if [ "$DATA" == "" ] || [ "$DATA" == "files" ]; then
FILES="true"
fi
## Install server dependencies.
# Install software to extract zip files.
fin exec 'sudo apt-get update -y && sudo apt-get install bsdtar -y'
# Install Node
fin exec 'curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -'
fin exec 'sudo apt-get install -y nodejs'
# Install gulp globally.
fin exec 'sudo npm install -g gulp'
## Run platform build.
fin exec 'platform build'
# If settings.local.php does not exist, create it from the template
if [[ ! -f "${PROJECT_ROOT}/_www/sites/default/settings.local.php" ]]; then
cp "${PROJECT_ROOT}/.docksal/other/docksal.settings.php" "${PROJECT_ROOT}/_www/sites/default/settings.local.php"
fi
## Grab user files if parameter is set.
if [ "$FILES" == "true" ]; then
fin import-user-files
fi
## Grab db if parameter is set.
if [ "$DB" == "true" ]; then
fin import-db true
fi
@lmakarov running source ~/.profile inside fin bash worked.
@lmakarov
Finally, I came up to this solution to use npm version that I need:
#!/usr/bin/env bash
#: exec_target = cli
## Install specific version of NPM
##
## Usage: fin install-npm-cli
# Abort if anything fails
set -e
echo "Installing NPM..."
source ~/.profile
nvm install 10.7.0
nvm use 10.7.0
Also using 2.2 version of cli.
14:08:11 ~/Projects/test
Β§ fin v
1.60.2
14:08:13 ~/Projects/test
Β§ fin config | grep image
image: docksal/cli:2.2-php7.1
image: docksal/db:1.2-mysql-5.6
image: phpmyadmin/phpmyadmin
image: docksal/solr:1.0-solr4
image: docksal/web:2.1-apache2.4
14:08:18 ~/Projects/test
Β§ fin bash
docker@cli:/var/www$ npm --version
6.1.0
docker@cli:/var/www$ ^C
14:09:16 ~/Projects/test
Β§ fin exec npm --version
6.1.0
Custom command:
14:24:37 ~/Projects/test
Β§ cat .docksal/commands/npm-test
#!/bin/bash
#: exec_target = cli
npm --version
14:24:34 ~/Projects/test
Β§ fin npm-test
6.1.0
npm definitely works in the latest stable fin and cli versions without any additional efforts.
I'm using cli:2.3-php7.2. Are you sure it is working there?
@croane I was replying to the comment https://github.com/docksal/docksal/issues/710#issuecomment-406361325 which assumed npm does not work in stable version of the image. I showed it works, and I checked the 6.1.0 which is installed in the stable image does have audit command.
2.3 is not stable and may contain bugs. Thanks for testing it! It would be easier for us to debug though, if it was stated in the title of the ticket.
You either need fin v1.60.2 (latest stable) and cli v2.2 or fin v1.65.0+ (dev version) and cli 2.3 to node/npm to work correctly. All other combinations will not work until Docksal 1.10.0 is released.
It looks like something was cached, after doing another build with `docksal/cli:2.2-php7.2, npm is working fine.
2.3 is not stable and may contain bugs
docksal/cli:2.3.0 has been released earlier this week and is IS stable, but to use it properly, you also need the latest Docksal/fin version, which has not yet been released.
@dealancer the approach you are using in https://github.com/docksal/docksal/issues/710#issuecomment-406366613 is correct.
The source ~/.profile line will not be necessary after the upcoming 1.10.0 Docksal release, but it's safe to keep it there for compatibility.
Thanks @dealancer, https://github.com/docksal/docksal/issues/710#issuecomment-406366613 works good for me!
Try that will solve
use Terminal
sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
once complete then install nodejs
sudo apt-get install nodejs
I'm going to lock this issue to prevent further misleading attempts to fix things.
Please read the summary below and open a new issue if you believe you ran into a different case not described below.
npm and node are both available out of the box in Docksal (docksal/cli).
There are only two possible cases when you would get npm: command not found :
CLI_IMAGE versions via docksal.env or you are using a custom stack where the version is pinned. In such cases, the project's cli container image version may become incompatible with the version of Docksal/fin installed. This does not happen often, but may still occur. It's recommended to use a default stack and avoid custom stacks and image version pinning, unless you know what you are doing.sudo npm install. Node in docksal/cli is installed via nvm at the docker user level. This means that it will only work when run by that default container user and won't work if run as root.