scratchfoundation / scratch-gui

Graphical User Interface for creating and running Scratch 3.0 projects.
https://scratchfoundation.github.io/scratch-gui/develop/
BSD 3-Clause "New" or "Revised" License
4.34k stars 3.44k forks source link

When I npm install scratch-gui, request to https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip failed #9012

Open tomorrow307 opened 1 year ago

tomorrow307 commented 1 year ago

scratch-gui@1.9.9 prepublish node scripts/prepublish.mjs

Downloading https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip FetchError: request to https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip failed, reason: connect ETIMEDOUT 162.125.32.10:443 at ClientRequest. (D:\lxj\myelectron\scratch\scratch-gui\node_modules\cross-fetch\node_modules\node-fetch\lib\index.js:1491:11) at ClientRequest.emit (node:events:369:20) at TLSSocket.socketErrorListener (node:_http_client:472:9) at TLSSocket.emit (node:events:369:20) at emitErrorNT (node:internal/streams/destroy:188:8) at emitErrorCloseNT (node:internal/streams/destroy:153:3) at processTicksAndRejections (node:internal/process/task_queues:81:21) { type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT' } npm ERR! code 1 npm ERR! path D:\lxj\myelectron\scratch\scratch-gui npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/prepublish.mjs

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\lxj\AppData\Local\npm-cache_logs\2023-06-20T08_28_43_088Z-debug.log

dbgoa commented 1 year ago

Is the problem solved?I'm having the same issue.

You548 commented 1 year ago

Please Download This : https://download.scratch.mit.edu/microbit/scratch-microbit.hex.zip

little8jie commented 12 months ago

I also encountered this issue in China and cannot open this address. How to solve it, thank you

IntzvDyunsi901 commented 12 months ago

if Browser download, please use this link:if browser download

JiafengLiao commented 12 months ago

Guys, Greetings from China, I solved it by manually downloading and extracting hex file plus a few lines of code modification.

Here are the steps:

  1. download zip file from "https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip" on browser or wget
  2. extract zip file to static/microbit。
  3. check "static\microbit\scratch-microbit-1.2.0.hex" exist
  4. modify function "downloadMicrobitHex" in "scripts\prepublish.mjs" as follow to skip downloading and extracting, and read hex file directly from local instead.
const downloadMicrobitHex = async () => {
    const relativeHexDir = path.join('static', 'microbit');
    const hexFileName = "scratch-microbit-1.2.0.hex"
    const relativeHexFile = path.join(relativeHexDir, hexFileName);
    const relativeGeneratedDir = path.join('src', 'generated');
    const relativeGeneratedFile = path.join(relativeGeneratedDir, 'microbit-hex-url.cjs');
    const absoluteGeneratedDir = path.join(basePath, relativeGeneratedDir);
    fs.mkdirSync(absoluteGeneratedDir, {recursive: true});
    const absoluteGeneratedFile = path.join(basePath, relativeGeneratedFile);
    fs.writeFileSync(
        absoluteGeneratedFile,
        [
            '// This file is generated by scripts/prepublish.mjs',
            '// Do not edit this file directly',
            '// This file relies on a loader to turn this `require` into a URL',
            `module.exports = require('./${path.relative(relativeGeneratedDir, relativeHexFile)}');`,
            '' // final newline
        ].join('\n')
    );
    console.info(`Wrote ${relativeGeneratedFile}`);
};

@tomorrow307 @dbgoa @little8jie

huangjiarong commented 12 months ago

2. microbit

thanks, i do it and solve the problem

lishenjian commented 10 months ago

cnmarky commented 10 months ago

@JiafengLiao thanks!

cocospy commented 10 months ago

excellent solution!

hunluanyuba commented 9 months ago

上边的朋友说得对,遇到这个问题的基本都是中国的,翻墙软件似乎并不能让npm翻墙 就是用浏览器下载https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip 加压后放在static\microbit\scratch-microbit-1.2.0.hex 最后修改scripts\prepublish.mjs中的downloadMicrobitHex函数代码看上边那个朋友的

Applewan commented 8 months ago

按照上面给出的方案,可以正常运行成功;但是我在运行 npm start 启动的时候,报错: ERROR in ./src/generated/microbit-hex-url.cjs Module not found: Error: Can't resolve './....staticmicrobitscratch-microbit-1.2.0.hex' in 'D:\Scratch\Scratch-Testing\scratch-gui\src\generated' 请问有没有什么好的解决方案?

JiafengLiao commented 8 months ago

按照上面给出的方案,可以正常运行成功;但是我在运行 npm start 启动的时候,报错: ERROR in ./src/generated/microbit-hex-url.cjs Module not found: Error: Can't resolve './....staticmicrobitscratch-microbit-1.2.0.hex' in 'D:\Scratch\Scratch-Testing\scratch-gui\src\generated' 请问有没有什么好的解决方案?

是完全按照步骤来的吗?看起来像是路径问题

jiafulu commented 8 months ago

@Applewan generated/microbit-hex-url.cjs module.exports = require('./../../static/microbit/scratch-microbit-1.2.0.hex');

nsgdsb commented 7 months ago

还是没有解决,该怎么办

nsgdsb commented 7 months ago

按照上面给出的方案,可以正常运行成功;但是我在运行 npm start 启动的时候,报错: ERROR in ./src/generated/microbit-hex-url.cjs Module not found: Error: Can't resolve './....staticmicrobitscratch-microbit-1.2.0.hex' in 'D:\Scratch\Scratch-Testing\scratch-gui\src\generated' 请问有没有什么好的解决方案?

最后您是怎么解决的

JiafengLiao commented 7 months ago

按照上面给出的方案,可以正常运行成功;但是我在运行 npm start 启动的时候,报错: ERROR in ./src/generated/microbit-hex-url.cjs Module not found: Error: Can't resolve './....staticmicrobitscratch-microbit-1.2.0.hex' in 'D:\Scratch\Scratch-Testing\scratch-gui\src\generated' 请问有没有什么好的解决方案?

最后您是怎么解决的

报错是啥

wudaochen commented 4 months ago

Hello! My issue is followed: ERROR in ./src/lib/microbit-update.js Module not found: Error: Can't resolve '../generated/microbit-hex-url.cjs' in 'E:\scratch-gui\src\lib' @ ./src/lib/microbit-update.js 12:0-55 84:23-29 @ ./src/containers/connection-modal.jsx @ ./src/components/gui/gui.jsx @ ./src/containers/gui.jsx @ ./src/playground/player.jsx Child HtmlWebpackCompiler: Asset Size Chunks Chunk Names child-HtmlWebpackPlugin_0 4.62 KiB HtmlWebpackPlugin_0 HtmlWebpackPlugin_0 Entrypoint HtmlWebpackPlugin_0 = child-HtmlWebpackPlugin_0 [./node_modules/html-webpack-plugin/lib/loader.js!./src/playground/index.ejs] 599 bytes {HtmlWebpackPlugin_0} [built] i 「wdm」: Failed to compile.

May I ask how you can solve this problem.

JiafengLiao commented 4 months ago

4. scripts\prepublish.mjs

looks like the path is not correctly set. For those who encountered "Can't resolve '****/microbit-hex-url.cjs'" problem. Please check your code in 'scripts\prepublish.mjs' with the code snippet I post. And check if microbit-hex-url.cjs stored in the path 'src/generate/'

gms335 commented 2 months ago

module.exports = require('./....\static\microbit\scratch-microbit-1.2.0.hex'); 这句中的“\”改成“/”,如下: module.exports = require('./../../static/microbit/scratch-microbit-1.2.0.hex');

XESDog commented 1 month ago

是否有高端一点的解法,scratch-desktop也报该问题,却没有相关的script去修改。

我本人有梯子,且设置了命令行代理(设置了http_proxy https_proxy all_proxy),能够通过wget https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip 下载到该文件。

但是,执行npm install 的时候依然报错,真是日了狗了。 npm ERR! FetchError: request to https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip failed, reason: connect ETIMEDOUT 156.233.67.243:443 npm ERR! at ClientRequest. (/Users/zheng/.npm/_cacache/tmp/git-cloneA5MTJ7/node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:1491:11) npm ERR! at ClientRequest.emit (node:events:517:28) npm ERR! at TLSSocket.socketErrorListener (node:_http_client:501:9) npm ERR! at TLSSocket.emit (node:events:517:28) npm ERR! at emitErrorNT (node:internal/streams/destroy:151:8) npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:116:3) npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { npm ERR! type: 'system', npm ERR! errno: 'ETIMEDOUT', npm ERR! code: 'ETIMEDOUT'

huiye19 commented 3 weeks ago

wudaochen

@wudaochen Hello, I met the same error with yours. May I know have you addressed it?

XBZD-WDD commented 12 hours ago
  1. scripts\prepublish.mjs

looks like the path is not correctly set. For those who encountered "Can't resolve '****/microbit-hex-url.cjs'" problem. Please check your code in 'scripts\prepublish.mjs' with the code snippet I post. And check if microbit-hex-url.cjs stored in the path 'src/generate/'