Magento 2 not loading CSS and JavaScript

Scott picture Scott · Dec 2, 2015 · Viewed 54.5k times · Source

I have installed magento 2 successfully on localhost but I am not able to see admin panel as it render 404 error to me.

Secondly, When I open front-end then CSS and JavaScript is not loading.They also renders 404 errors.

Also When I try to run command:

{your Magento install dir}/bin/magento setup:static-content:deploy

I got the following error

[InvalidArgumentException]                                              
There are no commands defined in the "setup:static-content" namespace.

Answer

Mohammed Anis picture Mohammed Anis · Dec 2, 2015

This One Worked for Me. use this Command php bin/magento setup:static-content:deploy

Step 1 : In CMD Open your root directory using cd command

Step 2 : php bin/magento setup:static-content:deploy - run this Command

then,Check Your pub/static folder, CSS and Js files will be available there

Refer this