Cannot access node in Laradock environment

Asked 2 years ago, Updated 2 years ago, 62 views

Problems

I am currently making a product in the React+Lavel environment.
Server-side rendering is required and is being built using spatie/larvel-server-side-rendering.
The local test environment was successful, but in the production Docker environment (using Laradock), the SettingNODE_PATH in this field will cause you to throw up errors.
Therefore, I would like to obtain the correct Node Path in the Laradock environment.

Error Messages

The command"~/home/laradock/.nvm/versions/node/v10.10.0/bin/node 
/var/www/storage/app/ssr/37e4a57537aad3ba32e697047bbf2914.js"failed.
Exit Code: 127 (Command not found)
Working directory: /var/www/publicOutput:
================ Error Output: ================
sh:1: /var/www/home/laradock/.nvm/versions/node/v10.10.0/bin/node —not found

Docker Container

9d81cb0602e3laradock_nginx "nginx" 2 hours ago Up 2 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcplaradock_nginx_1
668f7d68aaf0laradock_php-fpm "docker-php-entrypoi..." 2 hours ago Up 2 hours 9000/tcplaradock_php-fpm_1
c7d82a9c046e laradock_mysql "docker-entrypoint.s..."2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp laradock_mysql_1
f0929682024f laradock_workspace"/sbin/my_init"2 hours ago Up 2 hours 0.0.0.0:2222->22/tcp laradock_workspace_1
c190eef71c4f docker:dind "dockerd-entrypoint...."2 hours ago Up 2 hours 2375 / tcp laradock_docker-in-docker_1

Tried

  • In the local environment, /Users/ksk/.nodebrew/current/bin/node that appears in which node was moved as described in .env.

However, in a Docker environment, after attaching docker exec-it laradock_workspace_1bash, which node appears in /home/laradock/.nvm/versions/v10.0/bin/node in .env.
Also, setting NodePath /Users/ksk/.nodebrew/current/bin/node in the local environment resulted in the same error.

Ravel's .env file

APP_NAME=Larvel
APP_ENV=production
APP_KEY=*****************
APP_DEBUG = true
APP_LOG_LEVEL = debug
APP_URL = http://localhost

NODE_PATH=/home/laradock/.nvm/versions/node/v10.10.0/bin/node

-----------------------------------------

`

`

Supplementary information (for example, FW/Tool Version)

  • Docker versionv18.06.1-ce
    -- Node installed using nvm in workspace (v10.10.0)
  • Lavel versionv5.5.40

In the first place, Docker's understanding is poor, and I am very sorry for the poor explanation, but I would appreciate it if you could let me know if you have similar experiences.

php node.js docker laravel

2022-09-30 19:39

1 Answers

Self-resolved.

When I defined the path of the workspace container, I realized that the path is throwing up errors because php-fpm works in the build environment.

So I will install node on php-fpm.

Add the following three lines to the php-fpm Docker-file

RUN apt-get install-ygnupg
RUN curl-sL https://deb.nodesource.com/setup_10.x | bash-
RUN apt-get install-y nodejs

After stopping the docker container, use the docker-compose build php-fpm to build & install

After attaching it to the container, the node will start, so after checking it, get the path with which node

/usr/bin/node so I set this and it worked well...


2022-09-30 19:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.