Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 带有时间函数的npm脚本抛出;sh:1:语法错误:单词意外(应为“)”)&引用; 问题描述_Node.js_Npm - Fatal编程技术网

Node.js 带有时间函数的npm脚本抛出;sh:1:语法错误:单词意外(应为“)”)&引用; 问题描述

Node.js 带有时间函数的npm脚本抛出;sh:1:语法错误:单词意外(应为“)”)&引用; 问题描述,node.js,npm,Node.js,Npm,在linux机器上,当我将任何脚本包装到time()函数中时,会出现以下错误: sh: 1: Syntax error: word unexpected (expecting ")") 复制问题的步骤 Package.json 更多 在终端上运行相同的命令会导致: > time(echo \"Error: no test specified\") "Error: no test specified" real 0m0.000s user 0m0.000s sys 0m0.

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

sh: 1: Syntax error: word unexpected (expecting ")") 
复制问题的步骤 Package.json 更多 在终端上运行相同的命令会导致:

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

real    0m0.000s
user    0m0.000s
sys 0m0.000s
版本,我正在使用
请添加package.json,很可能您在scripts>test下没有任何相关内容,然后您正在运行npm test,它会检查脚本运行其命令并抛出错误
{
  "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"