How to Install Node Modules Into Your Laravel Project

Install Yarn

i’m using yarn in my project development. so to install yarn that will deploy node modules, first you need to add yarn repository first, to add it simply run :

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

 

after added yarn repository to your source list, then you need to update it first.

sudo apt update

then install yarn it self

sudo apt install yarn

 

Using Yarn

To deploy node_modules inside your project, simply run yarn inside directory of your project. then first you need to go to your project directory, then run

yarn

that command will deploy node_modules also with json and lock yarn files. then to make node take an effect to your project, simply run

yarn run dev

 

Production

when you have finished your development, make sure to make yarn run as production, to do it simply run

yarn prod

 

Leave a comment