Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marsuch's avatar

npm not function

Hi, so I have another docker problem. And it's probably a broken npm. Which command does run, but like in some sandbox. Because nothing is happening.

It keeps telling me that a newer version of npm is available. But when I run the npm update command (npm install -g [email protected]), nothing happens. The npm run dev command doesn't do anything either, the only thing that seemed to work was npm install.

The output of npm install -g [email protected] looks like this:

npm verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 2ms
npm timing config:load:builtin Completed in 3ms
npm timing config:load:cli Completed in 3ms
npm timing config:load:env Completed in 0ms
npm timing config:load:project Completed in 4ms
npm timing config:load:file:/root/.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:/usr/local/etc/npmrc Completed in 1ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 15ms
npm timing npm:load:configload Completed in 15ms
npm timing npm:load:mkdirpcache Completed in 2ms
npm timing npm:load:mkdirplogs Completed in 1ms
npm verb title npm install [email protected]
npm verb argv "install" "--global" "[email protected]" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 3ms
npm timing npm:load:display Completed in 17ms
npm verb logfile logs-max:10 dir:/root/.npm/_logs
npm verb logfile /root/.npm/_logs/2022-07-20T04_00_51_989Z-debug-0.log
npm timing npm:load:logFile Completed in 7ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 46ms
npm http fetch GET 200 https://registry.npmjs.org/npm 539ms (cache miss)
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 5ms
npm timing idealTree:userRequests Completed in 4ms
npm http fetch GET 200 https://registry.npmjs.org/npm 32ms (cache hit)
npm timing idealTree:#root Completed in 62ms
npm timing idealTree:node_modules/npm Completed in 0ms
npm timing idealTree:buildDeps Completed in 65ms
npm timing idealTree:fixDepFlags Completed in 1ms
npm timing idealTree Completed in 79ms
npm timing reify:loadTrees Completed in 374ms
npm timing reify:diffTrees Completed in 8ms
npm timing reify:retireShallow Completed in 8304ms
npm timing reify:createSparse Completed in 1ms
npm http fetch GET 200 https://registry.npmjs.org/npm/-/npm-8.14.0.tgz 1671ms (cache miss)
npm timing reifyNode:node_modules/npm Completed in 1682ms
npm timing arborist:ctor Completed in 0ms
npm timing reify:diffTrees Completed in 15ms
npm timing reify:loadBundles Completed in 2056ms
npm timing reify:unpack Completed in 1ms
npm timing reify:unretire Completed in 2ms
npm timing build:queue Completed in 40ms
npm timing build:link:node_modules/npm Completed in 13ms
npm timing build:link:node_modules/npm/node_modules/@npmcli/arborist Completed in 13ms
npm timing build:link:node_modules/npm/node_modules/@npmcli/installed-package-contents Completed in 14ms
npm timing build:link:node_modules/npm/node_modules/color-support Completed in 15ms
npm timing build:link:node_modules/npm/node_modules/mkdirp Completed in 15ms
npm timing build:link:node_modules/npm/node_modules/node-gyp Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/nopt Completed in 15ms
npm timing build:link:node_modules/npm/node_modules/pacote Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/opener Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/qrcode-terminal Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/rimraf Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/semver Completed in 16ms
npm timing build:link:node_modules/npm/node_modules/which Completed in 17ms
npm timing build:link:node_modules/npm/node_modules/npm-packlist Completed in 18ms
npm timing build:link Completed in 22ms
npm timing build:deps Completed in 63ms
npm timing build Completed in 64ms
npm timing reify:build Completed in 66ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 298ms
npm timing auditReport:getReport Completed in 306ms
npm timing auditReport:init Completed in 0ms
npm timing reify:audit Completed in 308ms
npm timing reify:trash Completed in 242ms
npm timing reify Completed in 11080ms

changed 22 packages, and audited 202 packages in 12s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm timing command:install Completed in 11674ms
npm verb exit 0
npm timing npm Completed in 11901ms
npm info ok

docker-compose.yml looks like this:.

version: '3.3'

################################################################################
# SERVICES
################################################################################
services:

  # ------------------------------------------------------------
  # Nginx
  # ------------------------------------------------------------
  nginx:
    image: nginx:stable-alpine
    environment:
      API_HOST: ${DOCKER_API_HOST}
    restart: always
    ports:
      - "80:80"
    volumes:
      - ./:/var/www/html:cached
      - ./.dockerfiles/nginx/templates:/etc/nginx/templates
    depends_on:
      - php
      - mysql
      - adminer
      - mailhog
    networks:
      laravel:
        aliases:
          - nginx

  # ------------------------------------------------------------
  # MySQL Database
  # ------------------------------------------------------------
  mysql:
    image: mariadb:10.6
    restart: always
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - db_data:/var/lib/mysql
    networks:
      laravel:
        aliases:
          - mysql

  # ------------------------------------------------------------
  # Adminer
  # ------------------------------------------------------------
  adminer:
    image: adminer:latest
    restart: always
    environment:
      ADMINER_DEFAULT_SERVER: mysql
      ADMINER_DATABASE: ${DB_DATABASE}
      ADMINER_USER: ${DB_USERNAME}
      ADMINER_PASSWORD: ${DB_PASSWORD}
      ADMINER_DESIGN: ng9
    ports:
      - "8081:8080"
    depends_on:
      - mysql
    networks:
      laravel:
        aliases:
          - adminer

  # ------------------------------------------------------------
  # PHP
  # ------------------------------------------------------------
  php:
    image: git.j-hof.cz:5050/docker/laravel-php:master
    volumes:
      - ./:/var/www/html:cached
    networks:
      laravel:
        aliases:
          - php

  # ------------------------------------------------------------
  # Redis
  # ------------------------------------------------------------
#  redis:
#    image: redis:alpine
#    container_name: redis
#    restart: always
#    ports:
#      - 6379:6379
#    networks:
#      laravel:
#        aliases:
#          - redis

  # ------------------------------------------------------------
  # Composer 2
  # ------------------------------------------------------------
  composer:
    image: composer:2
    volumes:
      - ./:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    user: root
    entrypoint: ['composer', '--ignore-platform-reqs']
    networks:
      laravel:
        aliases:
          - composer

  # ------------------------------------------------------------
  # NPM
  # ------------------------------------------------------------
  npm:
    image: node:16.16
    volumes:
      - ./:/var/www/html
    ports:
      - "3000:3000"
      - "3001:3001"
    working_dir: /var/www/html
    entrypoint: ['npm']
    networks:
      laravel:
        aliases:
          - npm

  # ------------------------------------------------------------
  # Laravel ARTISAN
  # ------------------------------------------------------------
  artisan:
    image: git.j-hof.cz:5050/docker/laravel-php:master
    volumes:
      - ./:/var/www/html:cached
    working_dir: /var/www/html
    entrypoint: ['php', '/var/www/html/artisan']
    depends_on:
      - mysql
      - php
    networks:
      laravel:
        aliases:
          - artisan


  # ------------------------------------------------------------
  # MailHog
  # ------------------------------------------------------------
  mailhog:
    image: mailhog/mailhog:latest
    container_name: mailhog
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      laravel:
        aliases:
          - mailhog

################################################################################
# NETWORK
################################################################################
networks:
  laravel:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"

################################################################################
# VOLUMES
################################################################################
volumes:
  db_data:
    driver: local
0 likes
9 replies
Sinnbeck's avatar

I don't see any errors in what you posted?

npm timing command:install Completed in 11674ms

Is there anything that isn't currently working?

marsuch's avatar

@Sinnbeck And that's the point of the bugs it doesn't show any. When I try to compile with npm run dev I get code 243. Regardless of whether I run as root or without sudo.

This error should be a permissions error which I tried to fix using:

sudo chown -R $(id -u):$(id -g) ~/.npm

But this is without result, I even tried to change the version of node to latest. Remove the image for node and create it again and nothing

Sinnbeck's avatar

@marsuch pretty sure that minor version of npm shouldn't make any difference. Can you install and compile your assets?

marsuch's avatar

@Sinnbeck And that's the point of the bugs it doesn't show any. When I try to compile with npm run dev I get code 243. Regardless of whether I run as root or without sudo.

This error should be a permissions error which I tried to fix using:

sudo chown -R $(id -u):$(id -g) ~/.npm

But this is without result, I even tried to change the version of node to latest. Remove the image for node and create it again and nothing

Sinnbeck's avatar

@marsuch can you show the error you get with npm run dev? Not just the error number

Sinnbeck's avatar

And personally I would use my Dockerfile to upgrade it :)

RUN npm install -g npm

marsuch's avatar

@Sinnbeck

npm verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 2ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:/var/www/html/.npmrc Completed in 0ms
npm timing config:load:project Completed in 4ms
npm timing config:load:file:/root/.npmrc Completed in 0ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 2ms
npm timing config:load Completed in 16ms
npm timing npm:load:configload Completed in 16ms
npm timing npm:load:mkdirpcache Completed in 6ms
npm timing npm:load:mkdirplogs Completed in 1ms
npm verb title npm run dev
npm verb argv "run" "dev" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 2ms
npm timing config:load:flatten Completed in 3ms
npm timing npm:load:display Completed in 15ms
npm verb logfile logs-max:10 dir:/root/.npm/_logs
npm verb logfile /root/.npm/_logs/2022-07-20T09_21_20_422Z-debug-0.log
npm timing npm:load:logFile Completed in 9ms
npm timing npm:load:timers Completed in 1ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 54ms
[..................] | : timing npm:load Completed in 54ms
> dev
> npm run development

npm http fetch GET 200 https://registry.npmjs.org/npm 576ms (cache miss)

npm timing command:run Completed in 626ms
npm notice
npm notice New minor version of npm available! 8.13.2 -> 8.14.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.14.0
npm notice Run npm install -g [email protected] to update!
npm notice
npm verb exit 243
npm timing npm Completed in 699ms
npm verb code 243

If I don't use sudo, it writes ERROR: 243 at the end. For example, it doesn't even save the log even though the listing shows its path

marsuch's avatar

@cbj4074 Hey, half and half. I haven't figured out the cause, but I've found a solution.

The problem was twofold: 1)I couldn't update npm 2)I couldn't compile the files using npm run dev.

The first problem sort of solved itself, the problem was probably on the source code side. The next day I was able to update npm normally.

I solved the second problem by starting to run the unabridged version, npm run development.

1 like

Please or to participate in this conversation.