‘yarn watch’在遵循Tensorflow.js入门教程时有什么问题?

huangapple go评论69阅读模式
英文:

What's wrong with 'yarn watch' when I follow the Tensorflow.js getting started tutorial?

问题

I executed 'yarn watch' in the getting-started directory and this happened:

yarn run v1.22.19
$ npm run build && node_modules/http-server/bin/http-server dist -p 1234

tfjs-examples-micro@0.1.0 build
mkdir -p dist/ && cp index.html dist/ && cp index.js dist/

The syntax of the command is incorrect.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm on Windows 11

I followed the tutorial to the letter and got this error, I was expecting the model example to run.

英文:

I executed 'yarn watch' in getting-started directory and this happend:

yarn run v1.22.19
$ npm run build && node_modules/http-server/bin/http-server dist -p 1234

> tfjs-examples-micro@0.1.0 build
> mkdir -p dist/ && cp index.html dist/ && cp index.js dist/

The syntax of the command is incorrect.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm on Windows 11

I followed the tutorial to the letter and got this error, I was expecting the model example to run

答案1

得分: 1

  1. 在我的 Windows 11 机器上执行 'yarn watch' 时,我也遇到了相同的情况。经过几次尝试,通过以下步骤使其工作:

    1. 编辑 "package.json" 并更新以下行:

      "scripts": {
      "watch": "npm run build && http-server dist -p 1234 ",
      "build": "mkdir dist && copy index.html dist && copy index.js dist"
      },

  2. 通过以下方式单独安装 http-server:

    npm install -g http-server

    因为我在从 "node_modules/http-server/bin" 运行 http-server 时遇到了问题。如果 http-server 在不需要单独安装的情况下正常工作,请忽略此步骤。

  3. 然后执行 "yarn watch",它就像魔法般地运行了。

这里唯一的问题是,每次在运行 "yarn watch" 之前,您都需要手动删除 "dist" 文件夹。也许我们可以在 "package.json" 中包括一个目录删除命令,以避免手动删除此文件夹。

希望这有所帮助。

谢谢

英文:

I also had faced the same situation while executing 'yarn watch' from my Windows 11 machine. After few tries, made it to work by taking these steps.

1.Edited "package.json" and updated the following lines from

  "scripts": {
    "watch": "npm run build && node_modules/http-server/bin/http-server dist -p 1234 ",
    "build": "mkdir -p dist/ && cp index.html dist/ && cp index.js dist/"
  },

to

  "scripts": {
    "watch": "npm run build && http-server dist -p 1234 ",
    "build": "mkdir dist && copy index.html dist && copy index.js dist"
  },

2.Installed http-server separately through

> npm install -g http-server

as I was having troubles with running http-server from "node_modules/http-server/bin". If http-server is working fine for you without installing it separately, please discard this step.

3.Then executed "yarn watch" and it worked like a charm.

Only problem here is that, each time before you run "yarn watch", you will have to manually remove the "dist" folder. May be we can include a directory removal command also in the "package.json" to avoid manual removal of this folder.

Hope this helps.

Thank you

答案2

得分: 0

我通过以下方法使其工作:

启动构建脚本的每个子命令:

对于Linux:

  • mkdir -p dist/
  • cp index.html dist/
  • cp index.js dist/

对于Windows:

  • mkdir -p dist
  • copy index.html dist
  • copy index.js dist

然后使用以下命令启动服务器:

  • http-server dist -p 1234
英文:

I managed to make it work by :

Launching individually each subcommand of the build script
for linux

  • mkdir -p dist/
  • cp index.html dist/
  • cp index.js dist/

for windows

  • mkdir -p dist
  • copy index.html dist
  • copy index.js dist

And then this command to start the server

  • http-server dist -p 1234

huangapple
  • 本文由 发表于 2023年3月9日 23:32:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75686774.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定