Answers.Body: <p>I encountered the same issue and found that civicrm/packages/TbsZip/tbszip.php file is missing. Restoring the file fixed this issue.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-25T10:40:05.777Z
Answers.LastActivityDate: 2017-12-25T10:40:05.777Z
Answers.UserDisplayName: Monish Deb
Answers.Body: <p>Here are some places to check:</p>
  
  <ul>
  <li>The JavaScript file name you mentioned shows that you're using aggregated JavaScript.  To troubleshoot this, temporarily <a href="https://www.drupal.org/node/2866077" rel="nofollow noreferrer">disable aggregated Javascript</a>.</li>
  <li>If that solves your problem by itself, it's probably just a caching issue.  Clear caches and reenable JS aggregation.  More likely though, it will just make debugging easier (e.g. by showing the actual JS file throwing the error).</li>
  <li>Use the "Network" tab in your browser's developer tools once JS aggregation is off to look for 404 errors.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-31T16:26:23.360Z
Answers.Text: Thanks for the help. I do have JS aggregation turned off. I just added $config['system.performance']['js']['preprocess'] = TRUE; to my settings.php file as per the post that you linked to, just to verify. I'm still getting the same results. One of the errors I neglected to add to the error message is: 'civicrm/admin/messageTemplates/add?action=add&reset=1 500 (Internal Server Error)'
Answers.UserDisplayName: spinsheet
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T01:13:25.277Z
Answers.Text: You may be getting the same results - but if your JS is no longer aggregated, then your console should report the JS error in a different filename, which should be a clue.  Did you find any 404 errors?
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T12:50:36.147Z
Answers.Text: I didn't see any 404 errors but there was the following 500 error:
  GET https://www.example.org/civicrm/admin/messageTemplates/add?action=add&reset=1 500 (Internal Server Error)
  
  Where 'example' is replacing the actual URL. So for some reason even after setting my JS not to aggregate it's still aggregating.
Answers.UserDisplayName: spinsheet
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T15:45:49.773Z
Answers.Text: I found that in the file sites/all/modules/civicrm/CRM/Utils/PDF/Document.php there is a line require_once 'TbsZip/tbszip.php that was throwing the following error in the Drupal logs: Warning: require_once(TbsZip/tbszip.php): failed to open stream: No such file or directory in require_once() (line 34 of /var/www/html/EXAMPLE/sites/all/modules/civicrm/CRM/Utils/PDF/Document.php). I commented that line out and now everything seems to work. Not sure what the repercussions of that are, or why it works on Test and not Prod.
Answers.UserDisplayName: spinsheet
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-31T16:14:56.087Z
Answers.LastActivityDate: 2017-08-31T16:14:56.087Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>When I try to create and new, or edit an existing, message template in 'Mailings' > 'Messsage Templates' I end up at a completely unstyled page. When I look at the console I see the following error:</p>
  
  <pre><code>Uncaught ReferenceError: CRM is not defined
  at BtJa0AvQ:153
  </code></pre>
  
  <p>I then look at the 'file' that is being referenced and at the very last line I see:</p>
  
  <pre><code>})(CRM.$);
  </code></pre>
  
  <p>I have a Test server which is rendering the mail templates fine, it's simply the Prod server (which figures...) where I'm having this issue.</p>
  
  <p>Any ideas where I can troubleshoot this issue?</p>
  
  <p>I'm using the following:</p>
  
  <ul>
  <li>Drupal 7.56</li>
  <li>CiviCRM 4.7.22</li>
  <li>PHP 5.5.38</li>
  <li>Amazon Linux AMI release 2017.03</li>
  <li>Apache 2.4.27</li>
  </ul>
  
  <p>I'm only using one extension but that extension has nothing to do with mailing and was actually added well after this problem surfaced.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-31T15:56:38.893Z
Comments.Text: Can you please edit your question to indicate the CiviCRM version and CMS you're using?  Are you using any extensions that affect mail, like Mosaico and/or Flexmailer?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-31T16:11:35.733Z
Comments.Text: Thanks for the updated info!  I can give you some troubleshooting ideas now (see below)
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <error><mailing>
Title: Uncaught ReferenceError: CRM is not defined when trying to access mail templates
ThreadText: # Uncaught ReferenceError: CRM is not defined when trying to access mail templates
  
  (Asked by: username_0 on 2017-08-31)
  
  When I try to create and new, or edit an existing, message template in 'Mailings' > 'Messsage Templates' I end up at a completely unstyled page. When I look at the console I see the following error:
  
  ```
  Uncaught ReferenceError: CRM is not defined
  at BtJa0AvQ:153
  
  ```
  
  I then look at the 'file' that is being referenced and at the very last line I see:
  
  ```
  })(CRM.$);
  
  ```
  
  I have a Test server which is rendering the mail templates fine, it's simply the Prod server (which figures...) where I'm having this issue.
  
  Any ideas where I can troubleshoot this issue?
  
  I'm using the following:
  
  * Drupal 7.56
  * CiviCRM 4.7.22
  * PHP 5.5.38
  * Amazon Linux AMI release 2017.03
  * Apache 2.4.27
  
  I'm only using one extension but that extension has nothing to do with mailing and was actually added well after this problem surfaced.
  
  **Tags:** error, mailing
  
  > **Comments:**
  > **username_1**: Can you please edit your question to indicate the CiviCRM version and CMS you're using?  Are you using any extensions that affect mail, like Mosaico and/or Flexmailer?  
  > **username_1**: Thanks for the updated info!  I can give you some troubleshooting ideas now (see below)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-12-25. Score: 2
  
  I encountered the same issue and found that civicrm/packages/TbsZip/tbszip.php file is missing. Restoring the file fixed this issue.
  
  
  ---
  
  ### Answer by username_1 on 2017-08-31. Score: 2
  
  Here are some places to check:
  
  * The JavaScript file name you mentioned shows that you're using aggregated JavaScript. To troubleshoot this, temporarily [disable aggregated Javascript](https://www.drupal.org/node/2866077).
  * If that solves your problem by itself, it's probably just a caching issue. Clear caches and reenable JS aggregation. More likely though, it will just make debugging easier (e.g. by showing the actual JS file throwing the error).
  * Use the "Network" tab in your browser's developer tools once JS aggregation is off to look for 404 errors.
  
  > **Comments:**
  > **username_0**: Thanks for the help. I do have JS aggregation turned off. I just added $config['system.performance']['js']['preprocess'] = TRUE; to my settings.php file as per the post that you linked to, just to verify. I'm still getting the same results. One of the errors I neglected to add to the error message is: 'civicrm/admin/messageTemplates/add?action=add&reset=1 500 (Internal Server Error)'  
  > **username_1**: You may be getting the same results - but if your JS is no longer aggregated, then your console should report the JS error in a different filename, which should be a clue.  Did you find any 404 errors?  
  > **username_0**: I didn't see any 404 errors but there was the following 500 error: GET https://www.example.org/civicrm/admin/messageTemplates/add?action=add&reset=1 500 (Internal Server Error)  Where 'example' is replacing the actual URL. So for some reason even after setting my JS not to aggregate it's still aggregating.  
  > **username_0**: I found that in the file sites/all/modules/civicrm/CRM/Utils/PDF/Document.php there is a line require_once 'TbsZip/tbszip.php that was throwing the following error in the Drupal logs: Warning: require_once(TbsZip/tbszip.php): failed to open stream: No such file or directory in require_once() (line 34 of /var/www/html/EXAMPLE/sites/all/modules/civicrm/CRM/Utils/PDF/Document.php). I commented that line out and now everything seems to work. Not sure what the repercussions of that are, or why it works on Test and not Prod.  
  
  ---
  
  