Angular`ng update @angular / ...`返回`401 Unauthorized`

时间:2018-05-04 17:57:56

标签: angular angular-cli angular6

npm -v返回6.0.0

node -v返回v10.0.0

Angular CLI本地和全球版本为6.0.0

我创建了一个包含ng new sample的新包,运行npm install没有问题,然后我尝试ng update @angular/coreng update @angular/cli并获得401 Unauthorized作为回应。< / p>

尝试在已经安装的Angular 6存储库上运行更新似乎是多余的,但我对Angular 5存储库也有这个问题。

ng5-sample git:(ng6) ✗ ng update @angular/core, 401 Unauthorized

我没有太多可以继续解决此错误,是否应该专门针对ng update进行操作,或者更可能在其外部进行一些不相关的配置?

4 个答案:

答案 0 :(得分:16)

我正在努力解决相同的错误消息。对我来说,它是由项目目录中的自定义.npmrc引起的,其中包含有关如何连接到我们的npm注册表的信息。

以下是我如何解决它:

  1. 在更新期间(mv .npmrc backup.npmrc
  2. 删除了该文件
  3. package.json
  4. 中删除了我们内部npm注册表中所有工件的依赖项
  5. ng update @angular/cli
  6. 将文件移回旧位置mv backup.npmrc .npmrc
  7. npm install(只是为了确保)
  8. 我还在https://github.com/angular/angular-cli/issues/10704

    创建了一个angular-cli问题

答案 1 :(得分:0)

偶然的机会,您在尝试更新时运行应用程序了吗? 我遇到了同样的问题,并且在停止应用程序进程并在全球范围内安装最新的cli之后能够从5.29更新到6.0.0。

答案 2 :(得分:0)

我有同样的问题。这是我的解决方法。

from tkinter import *
from tkinter import messagebox

valid1 = True
valid2 = True
valid3 = True
valid4 = True
valid5 = True

def saveCustomerDetails():
    CustomerIDSave = CustomerIDVar.get()
    CustomerIDSave = CustomerIDSave.ljust(25)

    CustomerTitleSave = CustomerTitleVar.get()
    CustomerTitleSave = CustomerTitleSave.ljust(25)

    FirstNameSave = FirstNameVar.get()
    FirstNameSave = FirstNameSave.ljust(25)

    SurnameSave = SurnameVar.get()
    SurnameSave = SurnameSave.ljust(25)

    DOBSave = DOBVar.get()
    DOBSave = DOBSave.ljust(25)

    fileObject = open("CreateAccount.txt","a")
    fileObject.write(CustomerIDSave + CustomerTitleSave + FirstNameSave + SurnameSave + DOBSave + "\n")
    fileObject.close()

def checkID():
    global valid1
    CustomerID = CustomerIDVar.get()

    if CustomerID.isdigit():
        valid1 = True
    elif CustomerID is "":
        valid1 = True
    else:
        valid1 = False

    if valid1 == False:
        messagebox.showerror("Incorrect", "Incorrect CustomerID")

def checkTitle():
    global valid2
    CustomerTitle = CustomerTitleVar.get()

    if CustomerTitle.isalpha():
        valid2 = True
    elif CustomerTitle is "":
        valid2 = True
    else:
        valid2 = False

    if valid2 == False:
        messagebox.showerror("Incorrect", "Incorrect CustomerID")

def checkFirstName():
    global valid3
    FirstName = FirstNameVar.get()

    if FirstName.isalpha():
        valid3 = True
    elif FirstName is "":
        valid3 = True
    else:
        valid3 = False

    if valid3 == False:
        messagebox.showerror("Incorrect", "Incorrect CustomerID")

def checkSurname():
    global valid4
    Surname = SurnameVar.get()

    if Surname.isalpha():
        valid4 = True
    elif Surname is "":
        valid4 = True
    else:
        valid4 = False

    if valid4 == False:
        messagebox.showerror("Incorrect", "Incorrect CustomerID")

def checkDOB():
    global valid5
    DOB = DOBVar.get()

    if DOB.isdigit():
        valid5 = True
    elif DOB is "":
        valid5 = True
    else:
        valid5 = False

    if valid5 == False:
        messagebox.showerror("Incorrect", "Incorrect CustomerID")

def makeWindow():

    global CustomerIDVar, CustomerTitleVar, FirstNameVar, SurnameVar, DOBVar

    win = Tk()
    win.geometry("700x300")

    frame1 = Frame(win)
    frame1.pack(side = LEFT)

    Label(frame1, text = "Create Account", font = ("Helvetica 12 bold")).grid(row = 0, column = 0)

    Label(frame1, text="Customer ID").grid(row=1, column=0, sticky=W)
    CustomerIDVar = StringVar()
    CustomerID = Entry(frame1, textvariable = CustomerIDVar)
    CustomerID.grid(row=1,column=1,sticky=W)

    Label(frame1, text="Customer Title").grid(row=2, column=0, sticky=W)
    CustomerTitleVar = StringVar()
    CustomerTitle = Entry(frame1, textvariable = CustomerTitleVar)
    CustomerTitle.grid(row=2,column=1,sticky=W)

    Label(frame1, text="First Name").grid(row=3, column=0, sticky=W)
    FirstNameVar = StringVar()
    FirstName = Entry(frame1, textvariable = FirstNameVar)
    FirstName.grid(row=3,column=1,sticky=W)

    Label(frame1, text="Last Name").grid(row=4, column=0, sticky=W)
    SurnameVar=StringVar()
    Surname= Entry(frame1, textvariable=SurnameVar)
    Surname.grid(row=4,column=1,sticky=W)

    Label(frame1, text="Date Of Birth").grid(row=5, column=0, sticky=W)
    DOBVar=StringVar()
    DOB = Entry(frame1, textvariable=DOBVar)
    DOB.grid(row=5,column=1,sticky=W)

    frame2 = Frame(win)
    frame2.pack()

    b1= Button(frame2, text="Submit", command=saveCustomerDetails)
    b1.pack(side = LEFT)

    return win

win = makeWindow()
win.mainloop() 

答案 3 :(得分:0)

如接受的答案所示,此问题来自在配置中的某个位置定义了自定义注册表。通过.rc文件(例如.yarnrc.npmrc或直接用npm config set registry <url>yarn config set <name>:registry <url>进行设置。您无需撤消这些注册表配置即可解决此问题! ng update命令将使用注册表URL作为参数。但是,您将必须删除对依赖于您的自定义注册表的软件包的任何引用。不用担心命令会告诉您什么是令人讨厌的软件包,只需像这样运行命令:

对于纱线:

ng update @angular/cli @angular/core --registry https://registry.yarnpkg.com

对于npm:

ng update @angular/cli @angular/core --registry https://registry.npmjs.org

应导致以下错误: Not found : @fortawesome/fontawesome-pro

然后,您可以从package.json中的依赖项中临时删除有问题的程序包,然后重试。