【问题标题】:I get an error when trying to install strapi尝试安装 strapi 时出现错误
【发布时间】:2023-01-03 23:33:58
【问题描述】:

尝试使用 npx create-strapi-app@latest my-project 安装 strapi 时

,出现错误。以前一切正常,现在不想安装了。一般来说,我无法在任何地方解决问题。还尝试重新安装 Python、node、sqlite3、gyp,但没有任何帮助。这是错误代码

Creating a new Strapi application at D:\next\traversy\my-project.
Creating files.
error D:\next\traversy\my-project\node_modules\better-sqlite3: Command failed.
Exit code: 1
Command: prebuild-install || npm run build-release
Arguments:
Directory: D:\next\traversy\my-project\node_modules\better-sqlite3
Output:
prebuild-install warn install No prebuilt binaries found (target=18.12.1 runtime=node arch=x64 libc= platform=win32)

> better-sqlite3@7.4.6 build-release
> node-gyp rebuild --release

gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@18.12.1 | win32 | x64
gyp info find Python using Python version 3.11.0 found at "C:\Users\zayts\AppData\Local\Programs\Python\Python311\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
gyp ERR! stack     at C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
gyp ERR! stack     at C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
gyp ERR! stack     at C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:385:16
gyp ERR! stack     at C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\zayts\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:420:5)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
gyp ERR! System Windows_NT 10.0.22000
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\zayts\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd D:\next\traversy\my-project\node_modules\better-sqlite3
gyp ERR! node -v v18.12.1
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok

Keep trying!

Oh, it seems that you encountered errors while installing dependencies in your project.
Don't give up, your project was created correctly.```

【问题讨论】:

    标签: strapi


    【解决方案1】:

    不知道为什么,但错误指出:

    gyp ERR! find VS **************************************************************
    gyp ERR! find VS You need to install the latest version of Visual Studio
    gyp ERR! find VS including the "Desktop development with C++" workload.
    gyp ERR! find VS For more information consult the documentation at:
    gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
    gyp ERR! find VS **************************************************************
    gyp ERR! find VS
    

    我猜你缺少一些节点 js 依赖项,你可能想重新下载节点并选中 Install Prerequisites 复选框 https://nodejs.org/en/download/

    该错误可能指向某些 VC_redist

    【讨论】:

    • 我只是尝试安装 strapi 但什么也没有出来
    • 错误字面意思是You need to install the latest version of Visual Studio including the "Desktop development with C++" workload.
    • 你的电脑上有一些旧版本的软件,在引擎盖下配置了一些东西,这就是为什么你有错误
    【解决方案2】:

    从 strapi 文档中检查最适合的节点版本。 https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/installation/cli.html#preparing-the-installation

    在我的例子中,我只是将我的节点版本从 18 降级到 16,并且 strapi 安装了所有东西,没有一个错误或警告。

    【讨论】:

      最近更新 更多