Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chocolately `Get-ExecutionPolicy` - Uncaught ReferenceError: Get is not defined

I am following the Chocolately Install steps (Windows 7), but have run into a couple of problems.

Firstly, I've opened Command Prompt (opening it with Run as administrator), but when trying to execute Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')), I get this error:

Uncaught SyntaxError: Unexpected identifier

..with the https: part of my command highlighted.

Further, when I try to execute Get-ExecutionPolicy, it results in:

Uncaught ReferenceError: Get is not defined

Any ideas what could be wrong?

* UPDATE *

When I try the same command in PowerShell, I get this error:

PS C:\Users\mylogin> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtoc ol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"." At line:1 char:85 + Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System. Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://ch ocolatey.org/install.ps1')) + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException

Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error occ urred on a send." At line:1 char:219 + Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.Se rvicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString <<<< ('https://ch ocolatey.org/install.ps1')) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

like image 204
ban-geoengineering Avatar asked May 25 '20 14:05

ban-geoengineering


People also ask

How to solve uncaught ReferenceError-$is not defined?

Solution 1: Using before defining - Uncaught ReferenceError: $ is not defined Case: Invoking the function or using a variable before declaring it. As you are aware, all javascript code is executed inside the browser such as Chrome, Mozilla, Safari, and IE.

Why do I get uncaught ReferenceError when using jQuery?

When you open the HTML in browser you will most likely get Uncaught ReferenceError. This is because all jQuery functions reference the jQuery library file and it has been not been referenced here, so you need to include references to it before any of your script tags that use jQuery. If you have not referenced it, then you will get an error.

Why do I get error $ is undefined in jQuery?

The common reason for this error behind is Uncaught ReferenceError: $ is not defined executing jquery code before loaded jQuery library file or not imported jQuery CDN in your file. Basically $ is the jQuery alias so when you try to call or access it before declaring the function. it will end up with throw $ is undefined.

What does the error $is not defined mean?

This indicates with an error saying "uncaught reference error $ is not defined". This is the most generic error even if you are working on Angular Js, Ajax, Html, and MVC, laravel or rails .. any framework which is related to javascript.


2 Answers

  1. Download chocolatey latest version from Chocolatey.org

  2. Rename file extension to .zip

  3. Extract the file

  4. Open PowerShell

  5. Open elevated PowerShell calling:

    Start-Process powershell -Verb runAs
    
  6. Go to the tools folder in the location where you extracted Chocolatey

  7. Call: & .\chocolateyInstall.ps1 to allow Chocolatey to install

  8. Add a path to the choco location to system environment PATH:

    C:\ProgramData\chocolatey\bin
    
  9. Restart your consoles, and VS Code (if you use one)

like image 123
Gopal Avatar answered Oct 16 '22 18:10

Gopal


Chocolatey.org requires TLS 1.2 to be able to connect. This error indicates that you don't have support for that installed:

System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"

The section from the blog post I linked to earlier should help:

If you find yourself provisioning machines such as Windows 7, Windows Server 2008, or older, you will find that those machines will not be able to communicate with the Chocolatey Community Repository after we implement this change. For those instances, you will need to use alternative installation methods for Chocolatey. We strongly recommend using the offline Chocolatey installation as it provides the most flexibility and reliability.

On the Chocolatey install page the requirements are listed:

  • Windows 7+ / Windows Server 2003+
  • PowerShell v2+ (minimum is v3 for install from this website due to TLS 1.2 requirement)
  • .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)(minimum is 4.5 for install from this website due to TLS 1.2 requirement)

My suggestion would be to fully patch your Windows 7 system, install .NET 4.5 and then try it. Remember Windows 7 has been out of support since January this year.

like image 24
pauby Avatar answered Oct 16 '22 18:10

pauby