Node.js 如何在windows中使用Thread运行简单的文件脚本

Node.js 如何在windows中使用Thread运行简单的文件脚本,node.js,windows,yarnpkg,Node.js,Windows,Yarnpkg,我对Node.js的整个世界都是新手,但这个可能很简单的问题让我发疯。这基本上是一个简化版的问题,我有一个更大的项目 文件结构 package.json test1 My package.json看起来是这样的: { "name": "Temp", "version": "1.0.0", "main": "index.js", "license": "MIT", "scripts": { "testscript": "test1", "testrun":"y

我对Node.js的整个世界都是新手,但这个可能很简单的问题让我发疯。这基本上是一个简化版的问题,我有一个更大的项目

文件结构

package.json
test1
My package.json看起来是这样的:

{
  "name": "Temp",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "testscript": "test1",
    "testrun":"yarn testscript"
  }
}
test1只包含一个简单的
console.log('test')
命令

现在,当我执行
纱线测试运行时
会出现以下错误:

PS C:\dev\temp> yarn testrun
yarn run v1.9.4
$ yarn testscript
$ test1
'test1' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
如果文件有一个扩展名(即test1.js),那么它会识别它并工作


在任何人说添加文件扩展名之前,这只是我创建的最简单的用例。有一个更大的项目包含这类东西,对我所有的Linux和Mac朋友来说似乎都很好。

你想要
节点测试1
。您现在正在尝试运行一个名为“test1”的不存在的程序。您希望现有的程序节点使用参数“test1”运行,该参数将告诉节点运行名为“test1.js”的JavaScript文件(或任何扩展名)

考虑文件:

因此:


键入:
节点test1
如:
“testscript”:“node test1”
是的,可以。很明显。我被它在Linux上运行良好的事实弄糊涂了。没有真正考虑过用“节点…”命令前缀它。
{
  "name": "Temp",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "testscript": "node test1",
    "testrun":"yarn testscript"
  }
}