Contact me: hankecnc@gmail.com

SyntaxError: Block-scoped declarations ? #545

推推 grbl 3年前 (2023-02-03) 314次浏览
关闭
9 个任务中的第 3 个
RossosHEX 开启了这个问题 2019 年 12 月 26 日 · 3条评论
关闭
9 个任务中的第 3 个

SyntaxError: Block-scoped declarations ?#545

RossosHEX 开启了这个问题 2019 年 12 月 26 日 · 3条评论

注释

SyntaxError: Block-scoped declarations ? #545

描述

尝试从命令行运行 cnc 时出现错误。

~/project_3D/cnc/cncjs$ cnc -v
Error: [SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode]
~/project_3D/cnc/cncjs$ cnc -h

  Usage: cnc [options]

  Options:

    -V, --version                       output the version number
    -p, --port <port>                   Set listen port (default: 8000) (default: 8000)
    -H, --host <host>                   Set listen address or hostname (default: 0.0.0.0) (default: 0.0.0.0)
    -b, --backlog <backlog>             Set listen backlog (default: 511) (default: 511)
    -c, --config <filename>             Set config file (default: ~/.cncrc)
    -v, --verbose                       Increase the verbosity level (-v, -vv, -vvv)
    -m, --mount <route-path>:<target>   Add a mount point for serving static files (default: )
    -w, --watch-directory <path>        Watch a directory for changes
    --access-token-lifetime <lifetime>  Access token lifetime in seconds or a time span string (default: 30d)
    --allow-remote-access               Allow remote access to the server (default: false)
    --controller <type>                 Specify CNC controller: Grbl|Marlin|Smoothie|TinyG|g2core (default: '') (default: )
    -h, --help                          output usage information

  Examples:

    $ cnc -vv
    $ cnc --mount /pendant:/home/pi/tinyweb
    $ cnc --mount /widget:~+/widget --mount /pendant:~/pendant
    $ cnc --mount /widget:https://cncjs.github.io/cncjs-widget-boilerplate/v1/
    $ cnc --watch-directory /home/pi/watch
    $ cnc --access-token-lifetime 60d  # e.g. 3600, 30m, 12h, 30d
    $ cnc --allow-remote-access
    $ cnc --controller Grbl

~/project_3D/cnc/cncjs$ cnc -V
1.9.20
~/project_3D/cnc/cncjs$ node -v
v4.9.1
~/project_3D/cnc/cncjs$ npm -v
2.15.11

安装是按照https://cnc.js.org/docs/installation/中的步骤执行的

该步骤npm install npm@latest -g正在对整个安装进行 gimping,在以后的尝试中省略了。
也必须做sudo rm -rf ~/.nvm/versions/node/几次。

版本

  • CNCjs:1.9.20
  • Node.js:v4.9.1
  • NPM:1.9.20

你如何安装CNCjs?

  • NPM
  • 下载 CNCjs 桌面应用程序

数控系统

  • Grbl
  • 冰沙
  • TinyG/g2核心

硬件

  • [] 树莓派
  • [x 台式机或笔记本电脑
  • 移动设备

操作系统

这些是我一直在执行的完整命令集:

git clone https://github.com/creationix/nvm.git ~/.nvm
cd ~/.nvm
git checkout `git describe --abbrev=0 --tags`
cd ..
chmod +x ~/.nvm/nvm.sh
. ~/.nvm/nvm.sh

# Add these lines to your ~/.bash_profile, ~/.bashrc, or ~/.profile file to have it automatically sourced upon login:
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

nvm install node

nvm install 4
nvm use 4

# npm install -g cncjs
npm install -g cncjs@latest --unsafe-perm

非常感谢任何帮助和/或建议。

SyntaxError: Block-scoped declarations ? #545
贡献者
米奇布拉德利 评论了 2019 年 12 月 27 日  

已知最新版本的 cncjs 可以在节点版本 8 和 10 上运行。版本 4 可能还为时过早。您可以尝试卸载节点并安装版本 8。

SyntaxError: Block-scoped declarations ? #545

谢谢你,米奇。

按照您的建议,我更改了nvm install 4 && nvm use 4tonvm install 8 && nvm use 8并再次运行命令。
一分钟后,它告诉我有些事情失败了。改npm install -g cncjs@latest --unsafe-permnpm install -g cncjs并编译了一些警告:

npm WARN deprecated bcrypt-nodejs@0.0.3: bcrypt-nodejs is no longer actively maintained. Please use bcrypt or bcryptjs. See https://github.com/kelektiv/node.bcrypt.js/wiki/bcrypt-vs-brypt.js to learn more about these two options
npm WARN deprecated superagent@3.8.3: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header).  This notice will go away with v5.0.2+ once it is released.
npm WARN deprecated core-js@1.2.7: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN react-datepicker@1.5.0 requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-datepicker@1.5.0 requires a peer of react-dom@^16.0.0 but none is installed. You must install peer dependencies yourself.

它不想通过cnc在终端中键入来启动。
不得不手动深入~/.nvm/versions/node/v8.17.0/bin/cnc研究哪个愉快地启动了应用程序。退出并再次尝试后cnc启动正常。也许它需要第一次运行配置?

不管怎样,我的机器现在可以愉快地运行 cncjs@1.9.20
再次感谢您的快速回复和季节问候!

附言。有人请修改安装指南,将 4 更改为 8。