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

ruckusman2's avatar

npm: command not found

I am on a homestead vm and trying to run npm install and get npm install - npm: command no found

What am I missing?

0 likes
10 replies
ejdelmonico's avatar

When you run npm/yarn on a Laravel project, make sure you are NOT in the vm. Only run artisan commands in the vm. Go to your project directory on your system and run it from there. The same thing for gulp.

1 like
ruckusman2's avatar

So, let me be sure i understand. Am I supposed to clone my app down into on my machine (in a sites folder or whatever I have defined) and then it syncs to the virtual machine or onto the virtual machine (homestead vagrant box) and then maybe it syncs back to my machine(sorry if this is dumb question). I have installed homestead, but on my machine even in the homestead directory while I can see composer files composer comes up as "command not found".

paulredmond's avatar

Homestead includes node along with "Yarn, PM2, Bower, Grunt, and Gulp" (listed right in the docs). I am actually not sure why you'd get that, but are you on the latest version of homestead?

I would try upgrading your Homestead VM, or at least re-provisioning

ruckusman2's avatar

So I am trying to follow these instructions. I can do some of this on the VM, but am I am I supposed to be on the VM, or in Homestead on my local machine?

@DJChrisBlue Create your own. I did, you can see my Laravel Starter project.

Then all you need to do each time is:

git clone https://github.com/mstnorris/laravel-starter new-project-name will clone the Laravel Starter project into a new directory called new-project-name cd new-project-name Run composer install / update if you want to update (may introduce new features BUT also; breaking changes) Run npm install Run gulp Add .env file Run php artisan app:name NAME_OF_YOUR_APP if you want to change the namespace Run php artisan key:generate Run php artisan migrate --seed from within your VM / or set the IP address of the DB_HOST to that of your VM Box. That's it! It includes User, Roles, and Permissions and a few other packages. I've been trying to add to it as and when I can.

ruckusman2's avatar

I can clone it down on VM fine.

I can run composer on VM fine,

But is that wrong, it seems that these directions pontificate I am on one machine the whole time. Plus when I watch a tutorial on youtube it seems they are on their local machine when they do it.

paulredmond's avatar

@ruckusman2 Your local project is mounted inside the VM so if you update it locally it will be updated inside the VM. That means you can run commands locally. However, it is better to run them all inside the VM because you will have a consistent environment free from any local changes you make to the node bin, NPM, etc.

The starter project you linked to assumes you are running the commands on the same machine, but doesn't make any assumptions of your environment being local or a VM. In your case, run them in homestead. If you are having problems running NPM in homestead, use my earlier suggestion to upgrade/re-install the homestead VM. I am not sure why you don't have npm, etc on your homestead box, it should be there.

ruckusman2's avatar

I am sorry for being stupid. I guess I feel like who is on first and what is on second. I go on my machine, I install VM, and Vagrant. I pull down homestead stuff. I use vagrant to launch homestead VM. I can now see my homestead vm machine in VB, etc. I can vagrant up, and vagrant ssh into it. I configure my homestead.yaml file. I cannot run any composer commants, npm commands from my home directory on my machine. I can't run them from the homestead directory on my machine. I can run composer commands on my Homestead VM machine when I ssh into it. I can't run NPM there but according to first guy I shouldn't be? Am I just not getting something? I can see the app that I pulled down from GITHub in my Homestead folder on my local machine so it seems I have done something right but I am just not quite there?

ruckusman2's avatar

I pulled the app down to my Homestead VM machine originally so to me that means that I have them syncing at least..

ruckusman2's avatar

When I go to myappname.app:8000 i get a no input file selected message.

_Rich's avatar

@ruckusman2 - You most likely have solved this by now, but if not, I had this message & my fix was to double check that my ~/homestead/Homestead.yaml file had the correct paths in mapping my local ~/Code folder to the appropriate folder in the virtual machine. To check the directory path that was used in the .yaml against the actual virtual directory I vagrant ssh from within the ~/Homestead folder then cd'd down to the public directory.

Please or to participate in this conversation.