AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题 / 76924207
Accepted
zfa- 2
zfa- 2
Asked: 2023-08-18 02:25:16 +0800 CST2023-08-18 02:25:16 +0800 CST 2023-08-18 02:25:16 +0800 CST

我的程序安装程序脚本在安装 Node.js 的 npm 后停止运行并且无法继续

  • 772

我有一个安装脚本,用于安装特定的 github 存储库及其所有要求。

这是似乎不一致的安装程序 snipit:

@echo off

REM Check if Python 3.11 is installed
python --version 2>&1 | findstr /I "3.11"
if %ERRORLEVEL% NEQ 0 (
    echo Python 3.11 is not installed. Please install Python 3.11 from the official website.
    exit /b 1
)

REM Check if Git is installed
where git > nul 2>&1
if %ERRORLEVEL% NEQ 0 (
    echo Git is not installed. Installing Git...
    powershell -Command "Start-Process https://git-scm.com/download/win -Wait"
)

REM Check if Node.js and npm are installed
node --version 2>&1 | findstr /I "v"
if %ERRORLEVEL% NEQ 0 (
    echo Node.js is not installed. Please install Node.js with npm from the official website.
    exit /b 1
)

REM Check if Python requests library is installed
pip show requests | findstr /I "Name: requests"
if %ERRORLEVEL% NEQ 0 (
    echo Installing requests...
    pip install requests
)

REM Set the installation directory to the user's home directory
set "repo_dir=%USERPROFILE%\algorithm-trader-warframe"
mkdir "%repo_dir%" 2>nul
cd /d "%repo_dir%"

REM Clone the Git repository into the specified directory
if exist "%repo_dir%\Warframe-Algo-Trader" (
    echo Repository is already cloned in %repo_dir%\Warframe-Algo-Trader.
) else (
    echo Cloning the Git repository into %repo_dir%\Warframe-Algo-Trader...
    git clone https://github.com/akmayer/Warframe-Algo-Trader
)

REM Install Python dependencies
pip install -r "%repo_dir%\Warframe-Algo-Trader\requirements.txt"
pip install uvicorn

REM Set the installation directory to the 'my-app' folder
cd /d "%repo_dir%\Warframe-Algo-Trader\my-app"

REM Check if Node.js dependencies are already installed
if exist "node_modules" (
    echo Node.js dependencies are already installed.
) else (
    echo Installing Node.js dependencies...
    npm install --no-fund

    REM Wait for npm installation to complete
    :WAIT_NPM_INSTALL
    if not exist "node_modules" (
        timeout /t 5 /nobreak > nul
        goto WAIT_NPM_INSTALL
    )
)

REM Go back to the main 'Warframe-Algo-Trader' folder
cd /d "%repo_dir%\Warframe-Algo-Trader"

REM Remove the existing config.json file (if it exists)
if exist "config.json" del "config.json"

REM Initialize the tables and create a new config.json file
python init.py

当不继续执行 python init.py 和其他脚本时,该问题始终会发生。一致的解决方案是运行脚本两次。现在我有一个理论,这可能是由于时间不当造成的,但除此之外,我无法在网上或通过 GPT 找到任何表明问题原因及其解决方案的内容。

我已经尝试添加超时和等待循环,但它似乎不起作用。该脚本总是在第二次运行时起作用,我想将其最小化为仅一次,而无需将所有内容缝合在一起。

node.js
  • 1 1 个回答
  • 24 Views

1 个回答

  • Voted
  1. Best Answer
    Magoo
    2023-08-18T04:34:29+08:002023-08-18T04:34:29+08:00

    嗯.. 对于常规批量生产商来说,第一个问题是 Mingw 正在运行的未提及的问题。

    Mingw 会覆盖一些标准批处理实用程序的正常操作,因此需要提及。

    我相信这不是问题。

    第一件事:“第二次工作”的原因通常是批处理文件的标准打开

    @echo off
    setlocal
    

    尚未被关注。这会在批处理结束时放弃对环境所做的任何更改,因此由一个批处理文件建立的变量不会影响可能在同一会话中运行的任何其他批处理。

    因此,结论是环境变量是由第一次运行建立的,在第一次运行结束时没有删除,然后在第二次运行中使用。

    因此,很可能set在第一次运行中执行一条语句,该语句建立了先前步骤中使用的变量。这可能是explicit(变量在脚本中通过名称提及)或implicit(变量由下标或实用程序使用)。或者可能是在第一次运行时建立了一个假定在某个时刻存在的目录,或者假定当前目录与其实际位置不同。

    所以候选人是

    repo_dir
    

    或由下标建立的某个变量或开始时的当前目录,因为似乎有cd未撤消的指令(setlocal批处理结束时恢复原始目录)

    所以 - 我建议在脚本开始时进行设置repo_dir,然后创建所需的子目录。

    下一个问题是it doesnt proceed with python init.py and the other scripts。由于python init.py 是最后一行,我认为这other scripts是问题所在 - 但我不知道它们是什么。也许运行它们取决于当前目录是否正确,也许取决于repo_dir.

    最后,

    REM Check if Node.js dependencies are already installed
    if exist "node_modules" (
        echo Node.js dependencies are already installed.
    ) else (
        echo Installing Node.js dependencies...
        npm install --no-fund
    
        REM Wait for npm installation to complete
        :WAIT_NPM_INSTALL
        if not exist "node_modules" (
            timeout /t 5 /nobreak > nul
            goto WAIT_NPM_INSTALL
        )
    )
    

    是行不通的。(带括号的语句序列code block)不能包含标签。

    REM Check if Node.js dependencies are already installed
    if exist "node_modules" (
        echo Node.js dependencies are already installed.
        goto nodejsinstalled
    )
    echo Installing Node.js dependencies...
    npm install --no-fund
    
    REM Wait for npm installation to complete
    :WAIT_NPM_INSTALL
    if not exist "node_modules" (
      timeout /t 5 /nobreak > nul
      goto WAIT_NPM_INSTALL
    )
    
    :nodejsinstalled
    

    更有可能工作

    • 0

相关问题

  • Rest-Api动态图像路径和Express除非

  • bcrypt 模块无法异步工作

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    使用 <font color="#xxx"> 突出显示 html 中的代码

    • 2 个回答
  • Marko Smith

    为什么在传递 {} 时重载解析更喜欢 std::nullptr_t 而不是类?

    • 1 个回答
  • Marko Smith

    您可以使用花括号初始化列表作为(默认)模板参数吗?

    • 2 个回答
  • Marko Smith

    为什么列表推导式在内部创建一个函数?

    • 1 个回答
  • Marko Smith

    我正在尝试仅使用海龟随机和数学模块来制作吃豆人游戏

    • 1 个回答
  • Marko Smith

    java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.http.ClientConfig.<init>(java.net.URI, java.time.Duration, java.time.Duratio

    • 3 个回答
  • Marko Smith

    为什么 'char -> int' 是提升,而 'char -> Short' 是转换(但不是提升)?

    • 4 个回答
  • Marko Smith

    为什么库中不调用全局变量的构造函数?

    • 1 个回答
  • Marko Smith

    std::common_reference_with 在元组上的行为不一致。哪个是对的?

    • 1 个回答
  • Marko Smith

    C++17 中 std::byte 只能按位运算?

    • 1 个回答
  • Martin Hope
    fbrereto 为什么在传递 {} 时重载解析更喜欢 std::nullptr_t 而不是类? 2023-12-21 00:31:04 +0800 CST
  • Martin Hope
    比尔盖子 您可以使用花括号初始化列表作为(默认)模板参数吗? 2023-12-17 10:02:06 +0800 CST
  • Martin Hope
    Amir reza Riahi 为什么列表推导式在内部创建一个函数? 2023-11-16 20:53:19 +0800 CST
  • Martin Hope
    Michael A fmt 格式 %H:%M:%S 不带小数 2023-11-11 01:13:05 +0800 CST
  • Martin Hope
    God I Hate Python C++20 的 std::views::filter 未正确过滤视图 2023-08-27 18:40:35 +0800 CST
  • Martin Hope
    LiDa Cute 为什么 'char -> int' 是提升,而 'char -> Short' 是转换(但不是提升)? 2023-08-24 20:46:59 +0800 CST
  • Martin Hope
    jabaa 为什么库中不调用全局变量的构造函数? 2023-08-18 07:15:20 +0800 CST
  • Martin Hope
    Panagiotis Syskakis std::common_reference_with 在元组上的行为不一致。哪个是对的? 2023-08-17 21:24:06 +0800 CST
  • Martin Hope
    Alex Guteniev 为什么编译器在这里错过矢量化? 2023-08-17 18:58:07 +0800 CST
  • Martin Hope
    wimalopaan C++17 中 std::byte 只能按位运算? 2023-08-17 17:13:58 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve