带时间函数的npm脚本抛出“sh:1:语法错误:单词意外(期待”)“)”

时间:2017-11-10 08:00:57

标签: node.js npm

问题描述

当我在linux机器上的time()函数中包装任何脚本时,出现以下错误:

sh: 1: Syntax error: word unexpected (expecting ")") 

重现问题的步骤

> mkdir hello-world
> cd hello-world
> npm init
> vim package & update test script to `"test": "time(echo \"Error: no test specified\")"`
> npm test

的package.json

{
  "name": "hello-world",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "time(echo \"Error: no test specified\")"
  },
  "author": "",
  "license": "ISC"
}

更多

在终端上运行相同的命令会导致:

> time(echo \"Error: no test specified\")
"Error: no test specified"

real    0m0.000s
user    0m0.000s
sys 0m0.000s

版本,我正在使用

"node": "~6.9.5",
"npm": "~3.10.10"

0 个答案:

没有答案