by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

Foreword

When developing Laravel, sometimes we need to install the nodejs package through npm, but Node in our system is not new enough.
It may be impossible to upgrade due to some factors, such as running an old version of nodejs program, etc.
In fact, we can use docker through simple commands, so that we can use the latest version of node image to mount the /sites folder on the host side.
In this way, we can execute the new version of the npm command at any time.

docker command

When we are in the folder of dlaravel, execute the following command:
docker run --rm -v ${PWD}/sites:/sites -w /sites -ti node bash

For example using the LTS version:
docker run --rm -v ${PWD}/sites:/sites -ti node:8.11.4 node npm -v

Let me explain them one by one:
run:    to execute a new container. (Run a command in a new container)
--rm:  Automatically remove the container when it stops.  (Automatically remove the container when it exits)
-v:      Bind mount a volume. (Bind mount a volume)
          This means that the data of the sites folder on the host side will be seen in the /sites folder in the container.
-w:     The default working directory is set to /sites here, so that after we enter the container, it will be in the /sites folder, which is D-Laravel's Projects Folder.
-t:       Allocate a pseudo-TTY
-i:       Keep STDIN open even if not attached
node: is the image we want to use.
bash: We want to execute the instructions in the container.

In other words, after executing the above command, we can enter the container.

You can enter ls to view the directory of the project.
Enter the Laravel Project directory,
You can easily npm install or npm run dev.

D-Laravel command (version 1.6.6)

Confirm the D-Laravel version.
./console version
D-Laravel release v1.6.6

way of entry
./console node

It's simpler, and when you use ./console alias to set it as an alias, it is equally effective and can be executed in any directory.






 

Tags: docker laravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


laravel

How do I upgrade the backend to Lravel 5.5

At the beginning, my background was a framework created by myself, which also uses MVC architecture, database connections and environment configuration files made by myself, including my own template syntax, until I want to support Restful, I have an idea, why should I rewrite the same function myself after others have written it, would it be better to write it out? So I started to use the framework, At the beginning, Slim was adopted mainly because it supports a lower version of php, but because Slim's twig templates are not as easy to use as Laravel's blade template...

php,docker,dlaravel

A brief introduction to the phpenv container environment I built

I don't have time to shoot an introduction video, so I'll just grab some pictures and introduce the container environment deviny/phpenv I use. https://github.com/DevinY/phpenvphpenv can be regarded as an evolutionary version of my previous D-Laravel open source project, conceptually extending the use of many Dlaravel operation methods. The update of the container tends to be controlled by the user to build his own image, so I am not very good at changing the version number. In fact, the php version number of D-Laravel seems to have not been changed for a long time:p

laravel

Laravel thought organization, from Model to DatabaseSeeder.

This article will introduce the relevant instruction use cases step by step: Model=>Factory=>Seeder=>DatabaseSeeder Step by step, let us examine all the processes from the Model to the DatabaseSeeder.