首页 > javascript > 我的NODE代码无法正常工作,因为我使用的是Windows而不是linux?

我的NODE代码无法正常工作,因为我使用的是Windows而不是linux? (Is my NODE code not working because im using windows not linux?)

问题

我在Windows CMD中收到此错误:

> fastify-website@1.0.0 build:get-releases C:\Users\Karol\Desktop\wbs
> src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0

'src' is not recognized as an internal or external command,
operable program or batch file.

我的package.json:

"name": "fastify-website",
  "version": "1.0.0",
  "description": "A static website builder for metalsmith",
  "scripts": {
    "build:cleanup": "rimraf build-temp",
    "build:create-temp-folder": "mkdirp build-temp",
    "build:get-releases": "src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0",

描述

所以基本上npm开始工作,直到它得到脚本“build:get-releases”...我尝试搞乱包json但没有帮助,同样,目录src / scripts / downloadReleases.js存在。

是因为它是典型的Linux和即时通讯使用Windows编写的?因为我准备安装linux如果它的真实,但我需要确认

(PS我直接从github下载这个,它应该工作,所以我的假设是linux可以正确读取package.json文件的这个特定内容)

解决方法

是的,因为你没有使用linux。

Windows有不支持shebangs,这downloadReleases.js用途。你可以在第1行看到它:

#!/usr/bin/env node

该行告诉操作系统在哪里为脚本找到合适的解释器。您或作者可以做的一个简单修复是在命令中使用解释器,如下所示:

node src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0

只要node安装了这些更改,Windows和Linux用户就可以运行脚本。

问题

I get this error in windows CMD:

> fastify-website@1.0.0 build:get-releases C:\Users\Karol\Desktop\wbs
> src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0

'src' is not recognized as an internal or external command,
operable program or batch file.

My package.json:

"name": "fastify-website",
  "version": "1.0.0",
  "description": "A static website builder for metalsmith",
  "scripts": {
    "build:cleanup": "rimraf build-temp",
    "build:create-temp-folder": "mkdirp build-temp",
    "build:get-releases": "src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0",

Description

so basically npm start works till it gets to script "build:get-releases"... I tried messing with package json but didnt help, also, the directory src/scripts/downloadReleases.js DOES exist.

Is it because it was written typically for linux and im using windows? Because im ready to install linux if its true, but i need confirmation

(PS i downloaded this straight from github and it should be working, so my assumption was linux can read this specific content of package.json file properly)

解决方法

Yes it is because you are not using linux.

Windows has no support for shebangs, which downloadReleases.js uses. You can see it on line 1:

#!/usr/bin/env node

That line tells the operating system where to find the proper interpreter for the script. A simple fix that you or the author could make would be to use the interpreter in the command like so:

node src/scripts/downloadReleases.js fastify/fastify build-temp/releases/ v0.11.0

This change would allow either windows and linux users to run the scripts as long as they have node installed.

相似信息