小编kax*_*993的帖子

未找到 - PUT https://npm.pkg.github.com/package-name

我正在尝试在 GPR(Github 包注册表)上上传一个包。我登录成功:

npm login --registry=https://npm.pkg.github.com
Run Code Online (Sandbox Code Playgroud)

然后运行这些命令:

npm set registry https://npm.pkg.github.com/

npm publish
Run Code Online (Sandbox Code Playgroud)

返回此错误:

npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/package-name
npm ERR! 404 
npm ERR! 404  'package-name@version' is not in the npm registry.
Run Code Online (Sandbox Code Playgroud)

似乎它试图在 npm 注册表而不是 github 包注册表上上传包。我应该如何解决这个问题?

javascript git github github-actions github-package-registry

20
推荐指数
3
解决办法
8697
查看次数

angular 2视图在ngOnInit中加载数据之前呈现

我使用github API在我的角度2应用程序中加载用户及其关注者数据,但在ngOnInit完成加载数据之前查看渲染,因此我收到: Cannot read property of undefined错误.我的代码片段如下所示:

ngOnInit() {
    Observable.forkJoin(
        this._githubService.getUser('kaxi1993'),
        this._githubService.getFollowers('kaxi1993')
    )
    .subscribe(res => {
        this.user = res[0];
        this.followers = res[1];
    },
    null,
    () => {
        this.isLoading = false;
    });
}
Run Code Online (Sandbox Code Playgroud)

如果我写这样的HTML代码:

 <div *ngIf="user && user.avatar_url">
   <img class="media-object avatar" [src]="user.avatar_url" alt="...">
 </div>
Run Code Online (Sandbox Code Playgroud)

工作正常,但Cannot read property 'avatar_url' of undefined写入HTML代码时返回错误,*ngIf如下所示:

<img class="media-object avatar" [src]="user.avatar_url" alt="...">
Run Code Online (Sandbox Code Playgroud)

还要注意:getFollowers工作正常,但如果我在方法getFollowers之前移动 然后工作正常,需要避免错误.是否可以在没有额外*ngIf代码的情况下编写?任何帮助的人,非常感谢.getUsersforkJoingetUsersgetFollowers*ngIf

javascript fork-join observable typescript angular

9
推荐指数
1
解决办法
6140
查看次数

如何在jquery插件中添加try catch块

我有一个jQuery插件.我想在我的jQuery插件中添加try catch块以进行异常处理.

我的插件

$(document).ready(function(){
$('.requiredclass').keyup(function() {


$(this).pluginMethod();

});
});

(function($) {  //i Want try catch block for this part

// jQuery plugin definition

$.fn.pluginMethod = function(e) {

       return this.each(function() {
       var $this = $.this; 
       var som= $this.val();

            //My Code goes here  

        });
};

})(jQuery);
Run Code Online (Sandbox Code Playgroud)

现在,如果我想添加try catch块,那么插件的外观如何?在jquery函数的情况下我们做这样的事情

功能

function myFunction() {
//varible declarations
try { 
    //Code goes here
}
catch(err) {  //We can also throw from try block and catch it here
    alert("err");
}
finally {
    //code for finally block
} …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-plugins

3
推荐指数
1
解决办法
1万
查看次数

Jest 快照测试错误:您不应在 &lt;Router&gt; 之外使用 &lt;Link&gt;

我想为我的Footer组件编写快照测试,但它抛出错误:You should not use <Link> outside a <Router>。这是我的代码:

import React from 'react'
import renderer from 'react-test-renderer'

import Footer from '../footer'

it('Footer renders correctly', () => {
    const tree = renderer
        .create(<Footer />)
        .toJSON()

    expect(tree).toMatchSnapshot()
})
Run Code Online (Sandbox Code Playgroud)

我知道发生这种情况是因为Footer组件使用Linkfrom react-router-dom. 为了解决这个问题,我将Footer组件包装在BrowserRouter

const tree = renderer
    .create(
        <BrowserRouter>
            <Footer />
        </BrowserRouter>
    )
    .toJSON()
Run Code Online (Sandbox Code Playgroud)

但现在它抛出错误:Browser history needs a DOM

javascript testing reactjs jestjs enzyme

3
推荐指数
1
解决办法
1326
查看次数

如何在nodejs中的postman中发布对象数组?

{
  graphName: String,
  lines: [{
    lineName: String,
    xyCoordinates: [
      x: Date,
      y: Number
    ]
  }]
}
Run Code Online (Sandbox Code Playgroud)

node.js postman

0
推荐指数
1
解决办法
1万
查看次数