小编Chr*_*eaf的帖子

如何列出 npm 中当前使用的 Node.js 版本和路径?

我目前遇到了与 Stackoverflow 问题相同的错误:SyntaxError: Use of const in strict mode? ,尽管我在尝试安装 Flux时得到了它。

我已经使用链接的 Stackoverflow 问题中显示的命令更新了系统的 Node.js 版本。

npm cache clean -f
sudo npm install -g n
sudo n stable
Run Code Online (Sandbox Code Playgroud)

当我运行时,node --version我得到了正确的版本,v8.2.1. 但是,当我通过 npm 安装模块时,我仍然收到警告,例如

npm WARN engine har-schema@1.0.5: wanted: {"node":">=4"} (current: {"node":"v0.10.25","npm":"1.3.10"})
Run Code Online (Sandbox Code Playgroud)

...这表明 npm 仍在使用旧版本的 Node。

有没有办法可以找到 npm 看到的 Node 版本,并且可以确定它的安装目录?

javascript bash ubuntu node.js

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

BufferedImageOp.filter()抛出通道错误

我试图实现用于反转每个像素的蓝色部分的算法BufferedImage使用BufferedImageOp类,如解释在这里.我的尝试导致了这种方法的创建:

private BufferedImage getInvertedVersion(BufferedImage source) {
     short[] invert = new short[256];
     short[] straight = new short[256];
     for (int i = 0; i < 256; i++) {
        invert[i] = (short)(255 - i);
        straight[i] = (short)i;
     }

     short[][] blueInvert = new short[][] { straight, straight, invert }; //Red stays the same, Green stays the same, Blue is inverted
     BufferedImageOp blueInvertOp = new LookupOp(new ShortLookupTable(0, blueInvert), null);

     //This produces error #1 when uncommented
     /*blueInvertOp.filter(source, source);
     return source;*/ …
Run Code Online (Sandbox Code Playgroud)

java image image-processing

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

什么是这种奇怪的三元运作?

我一直在阅读Flux库源代码,在一些地方我看到了这种表示法:

?: ?
Run Code Online (Sandbox Code Playgroud)

我不确定这是否是三元运算符的奇怪用法,或其他完全不同的东西.

FluxContainer.js文件的第245行开始的函数声明中可以找到几个混淆使用此例的好例子:

function createFunctional<Props, State, A, B>(
    viewFn: (props: State) => React.Element<State>,
    getStores: (props?: ?Props, context?: any) => Array<FluxStore>,
    calculateState: (prevState?: ?State, props?: ?Props, context?: any) => State,
    options?: Options,
): ReactClass<Props> {
    /** Omitted Implementation Details **/
};
Run Code Online (Sandbox Code Playgroud)

这里发生了什么,比如在props?: ?Props

javascript syntax flowtype

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

标签 统计

javascript ×2

bash ×1

flowtype ×1

image ×1

image-processing ×1

java ×1

node.js ×1

syntax ×1

ubuntu ×1