Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomorrow307 opened this issue Jun 20, 2023 · 31 comments

Comments

@tomorrow307
Copy link

[email protected] 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

@tomorrow307 tomorrow307 changed the title When I install scratch-gui, request to https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip failed When I npm install scratch-gui, request to https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip failed Jun 20, 2023
@dbgoa
Copy link

dbgoa commented Jul 3, 2023

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

@You548
Copy link

You548 commented Jul 7, 2023

@little8jie
Copy link

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

@ghost
Copy link

ghost commented Jul 21, 2023

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

@JiafengLiao
Copy link

JiafengLiao commented Jul 24, 2023

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
Copy link

2. microbit

thanks, i do it and solve the problem

@lishenjian
Copy link

@cnmarky
Copy link

cnmarky commented Sep 11, 2023

@JiafengLiao thanks!

@cocospy
Copy link

cocospy commented Sep 16, 2023

excellent solution!

@hunluanyuba
Copy link

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

@Applewan
Copy link

Applewan commented Nov 2, 2023

按照上面给出的方案,可以正常运行成功;但是我在运行 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
Copy link

按照上面给出的方案,可以正常运行成功;但是我在运行 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' 请问有没有什么好的解决方案?

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

@jfyear1994
Copy link

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

@nsgdsb
Copy link

nsgdsb commented Nov 22, 2023

还是没有解决,该怎么办

@nsgdsb
Copy link

nsgdsb commented Nov 22, 2023

按照上面给出的方案,可以正常运行成功;但是我在运行 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
Copy link

按照上面给出的方案,可以正常运行成功;但是我在运行 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' 请问有没有什么好的解决方案?

最后您是怎么解决的

报错是啥

@Chenchenweihang
Copy link

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
Copy link

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
Copy link

gms335 commented May 9, 2024

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

@XESDog
Copy link

XESDog commented Jun 14, 2024

是否有高端一点的解法,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
Copy link

huiye19 commented Jun 21, 2024

wudaochen

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

@XBZD-WDD
Copy link

  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/'

@daydayhappychao
Copy link

This isn't a great solution, I'd love some help with this.

@wulup1120
Copy link

是否有高端一点的解法,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'

解决了吗兄弟?解决了给我说下,我也是这个问题 到desktop就这个错误

@wulup1120
Copy link

@XESDog 解决了吗?

@xilinshuishi
Copy link

@XESDog 解决了吗?

这样修改可以:
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('./../../static/microbit/scratch-microbit-1.2.0.hex');,
'' // final newline
].join('\n')
);
console.info(Wrote ${relativeGeneratedFile});
};

@Sempre0721
Copy link

There is no generated folder in my directory, and I couldn't find any microbit-hex-url.cjs file.Where should I write "module.exports = require('./../../static/microbit/scratch-microbit-1.2.0.hex');"?

@Sempre0721
Copy link

I know how to console this problem.
just copy it:
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('./../../static/microbit/${hexFileName}');,
'' // final newline
].join('\n')
);
console.info(Wrote ${relativeGeneratedFile});
};

@xilinshuishi
Copy link

I know how to console this problem. just copy it: 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('./../../static/microbit/${hexFileName}');, '' // final newline ].join('\n') ); console.info(Wrote ${relativeGeneratedFile}); };

yes, you are right, cool

@Applewan
Copy link

Applewan commented Dec 10, 2024 via email

@cacf10
Copy link

cacf10 commented Jan 3, 2025

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

谢!终于搞定!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests