2

I'm using Magento 2.2.6 version, I already set to developer mode, but when I ran setup:upgrade, and when I open my Magento project the css and js not loaded.
But after I ran setup:static-content:deploy -f ,it backs to normal.

  • What mode are you running Magento 2 in? – Aditya Shah Sep 27 '18 at 4:49
  • @AdityaShah im in developer mode already, but my layout always broken after setup:upgrade , i need to run static-content:deploy – Tiny Dancer Sep 27 '18 at 5:06
  • @TinyDancer if your site have multi store then you need to setup:static-content:deploy -f with language. like en_US en_GB – Chirag Patel Sep 27 '18 at 5:11
  • It might be problem is related to grunt.js – Chirag Patel Sep 27 '18 at 5:12
  • @ChiragPatel i just installed the magento 2.2.6 with sample data, and it always make my page broken after setup:upgrade – Tiny Dancer Sep 27 '18 at 5:18
2

setup:upgrade cleans all the files in the directories

  1. /generated/code/
  2. /generated/metadata/
  3. /pub/static/
  4. and also deletes file deployed_version.txt

however force deploy - php bin/magento setup:static-content:deploy -f in developer mode regenerates all the above folders and files and recreates

  1. /pub/static/deployed_version.txt back again along with
  2. /var/view_preprocessed

hope this helps

1

The static view files deployment command enables you to write static files to the Magento file system when the Magento software is set for production mode.

The term static view file refers to the following:

  • “Static” means it can be cached for a site (that is, the file is not dynamically generated). Examples include images and CSS generated from LESS.
  • “View” refers to the presentation layer (from MVC).

Static view file deployment is affected by Magento modes as follows:

  • Default and developer modes: Magento generates them on demand, but the rest are cached in a file for speed of access.
  • Production mode: Static files are not generated or cached.

Solution

However, it only requires mode to be set to the developer in your case.

bin/magento deploy:mode:set developer
  • i already in developer mode – Tiny Dancer Sep 27 '18 at 5:10
0

How to view static content deploy errors in Magento 2?

Magento users when running php bin/magento setup:static-content:deploy have had some errors in their theme and they have to go through all the LESS file to check for errors manually. In fact, there are several types of errors that can be triggered by the deployment.

First you can see that Exception is handled directly in the execution

in Magento/Deploy/Console/Command/DeployStaticContentCommand.php:

catch (\Exception $e) {
    $output->writeln('<error>' . $e->getMessage() . '</error>>');
    if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) 
{
        $output->writeln($e->getTraceAsString());
    }
    return;
}

To regard the errors that are counted, you need to look into the Magento/Deploy/Model/Deployer class, and the output you got is written by the deploy() method:

$this->output->writeln("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n");

Now if you check when this errorCount variable is incremented, we will find the in the deployFile() method as below:

catch (\Exception $exception) {
    $this->output->write('.');
    $this->verboseLog($exception->getTraceAsString());
    $this->errorCount++;
}

And the verboseLog() method will just outputs when the command is run on verbose mode:

private function verboseLog($message)
{
if ($this->output->isVerbose()) {
    $this->output->writeln($message);
}
}

And then you need to run following command to see the errors:

php bin/magento setup:static-content:deploy -v

If it doesn't work, you will try the extra verbose:

php bin/magento setup:static-content:deploy -vv

php bin/magento setup:static-content:deploy -vvv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.