官方issue:https://github.com/LLK/scratch-blocks/issues/1620
在使用scratch-blocks时,遇到build编译失败,百度查了下解决方案,发现没有一篇能解决我这个问题,查不到相关的解决方案,于是我就去github的issue寻找是否有人与我相同遇到这种情况,查看了几篇文章终于发现了能解决的方案,分享给大家,希望能帮助到遇到相同问题的后来者~~
从官方网站下载scratch-blocks后执行cnpm i
下载依赖。
win10环境下,安装报错:
[npminstall:runscript] scripts.prepublish scratch-blocks@0.1.0 "python build.py&& webpack", root: "F:\\工作目录\\newScratch\\scratch-blocks\\scratch-blocks"
Traceback (most recent call last):
File "build.py", line 574, in <module>
test_proc = subprocess.Popen(test_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2]
× Install fail! Error: Run "C:\WINDOWS\system32\cmd.exe /d /s /c python build.py && webpack" error, exit code 1
Error: Run "C:\WINDOWS\system32\cmd.exe /d /s /c python build.py && webpack" error, exit code 1
at ChildProcess.proc.on.code (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cnpm\node_modules\runscript\index.js:74:21)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
无论使用npm run prepublish
和python build.py
都不好使。
找了很多博文都不顶用,都说window无法正常编译,于是根据线索直接去官方的issue查看是否有人和我一样遇到这个问题。翻了好几个issue之后,尝试了几个方法,终于找到个解决方法。
具体可以看issue的问题与回答:https://github.com/LLK/scratch-blocks/issues/1620
根据回答的方法修改build.py
1.找到大约331行的proc
,修改如下
# proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
outfile = open("dash_args.txt","w+")
outfile.write("\n".join(args[11:]))
outfile.close()
args = args[:11]
args.extend(['--flagfile','dash_args.txt'])
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell = True)
2.找到大约574行的test_proc
,修改如下
# test_proc = subprocess.Popen(test_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
test_proc = subprocess.Popen(test_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,shell=True)
修改完成后,就可以正常的编译执行了~~~
方法分享给大家,希望能帮助到遇到相同问题的后来者~~