小编fac*_*cVV的帖子

如何使用 loadVirtual 和 ENOLOCK 修复 npm 审计错误?

?   npm audit
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
Run Code Online (Sandbox Code Playgroud)

我运行 npm audit 并收到此错误。

当我在下面运行时:

? npm config get package-lock
true

? npm config get shrinkwrap
true
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?至于如何解决?并且 npm audit fix --force 也无法正常工作...

javascript node.js npm reactjs

11
推荐指数
4
解决办法
7481
查看次数

箭头函数可以在类中提升吗?(javascript)

class App {
  constructor() {
    this.canvas = document.createElement('canvas');
    document.body.appendChild(this.canvas);
    this.ctx = this.canvas.getContext('2d');

    this.pixelRatio = window.devicePixelRatio > 1 ? 2 : 1;

    window.addEventListener('resize', this.resize.bind(this), false);
    this.resize();

    window.requestAnimationFrame(this.animate);
  }

  resize() {
    this.stageWidth = document.body.clientWidth;
    this.stageHeight = document.body.clientHeight;
  }

  animate = () => {
    this.test(); // ---> here!
  };

  test = () => {
    console.log('here!');
  };
}

window.onload = () => {
  new App();
};
Run Code Online (Sandbox Code Playgroud)

箭头函数不会被提升,只有常规函数会被提升。为什么animate函数内部可以调用this.test?类中箭头函数的不同行为?

javascript hoisting

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

标签 统计

javascript ×2

hoisting ×1

node.js ×1

npm ×1

reactjs ×1