0

I encountered an error on running php bin/magento setup:di:compile on CLI

Error is :

  [Zend\Code\Exception\RuntimeException]
  No tokens were provided

How to fix this issue ?

1

After researching for some hours on this issue, I found the answer.

This issue occurs when there are any empty files inside our project folders.

Search those files using command.

grep -lr 'No tokens were provided' vendor/

You will see the results:

vendor/zendframework/zend-code/src/Scanner/ConstantScanner.php
vendor/zendframework/zend-code/src/Scanner/TokenArrayScanner.php
vendor/zendframework/zend-code/src/Scanner/MethodScanner.php
vendor/zendframework/zend-code/src/Scanner/PropertyScanner.php
vendor/zendframework/zend-code/src/Scanner/ClassScanner.php
if (!$this->tokens) {
        throw new \Zend\Code\Exception\RuntimeException('No tokens were provided');
    }

You can solve this by deleting those files using a command in CLI:

find ./ -size 0 -delete

OR

find ./ -type f -empty -delete

Now, Do run php bin/magento setup:di:compile again. Hope it helps to those who encounter this issue again.

| improve this answer | |

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.