相关疑难解决方法(0)

npm run <cmd>运行缓慢

我曾经通过Makefile运行各种命令但是对于nodejs项目,package.json是一个更合适的地方.

通过npm运行命令可以很好地工作,但与命令时间执行相比非常慢.

$ time ./node_modules/.bin/jshint . && ./node_modules/.bin/jscs .

real    0m0.759s
user    0m0.524s
sys 0m0.085s
No code style errors found.

$ time npm run lint

> @ lint /path/to/project
> jshint . && jscs .

No code style errors found.

real    0m2.246s
user    0m1.637s
sys 0m0.277s
Run Code Online (Sandbox Code Playgroud)

有可能加快速度吗?

UPD.我的package.json:

{
  "devDependencies": {
    "jscs": "^1.12.0",
    "jshint": "^2.6.3"
  },
  "scripts": {
    "lint": "jshint . && jscs ."
  }
}
Run Code Online (Sandbox Code Playgroud)

UPD2.我以错误的方式测量时间.甘特在他的评论中指出了这一点.现在两次看起来相似(100毫秒的差异).

$ time sh -c './node_modules/.bin/jshint . && ./node_modules/.bin/jscs .'
No code …
Run Code Online (Sandbox Code Playgroud)

performance node.js npm

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

标签 统计

node.js ×1

npm ×1

performance ×1