toyobayashi / cgen

3 stars 0 forks source link

这是为啥? #1

Closed OleeHu closed 2 years ago

OleeHu commented 2 years ago
PS E:\VS\cc++> cgen init demo
Error: Visual Studio 2022/2019/2017 is not found
    at Object.getvsinfo (D:\Node\node_global\node_modules\@tybys\cgen\bin\util\cmake.js:50:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getTemplateData (D:\Node\node_global\node_modules\@tybys\cgen\bin\actions\init.js:76:14)
    at async InitAction.onExecute (D:\Node\node_global\node_modules\@tybys\cgen\bin\actions\init.js:49:18)
    at async DynamicCommandLineParser.onExecute (D:\Node\node_global\node_modules\@tybys\cgen\node_modules\@rushstack\ts-command-line\lib\providers\CommandLineParser.js:199:13)
Exit: 1
toyobayashi commented 2 years ago

@OleeHu 检查一下有没有安装 VS,Visual Studio Installer 里有没有安装【使用 C++ 的桌面开发】工作负载

OleeHu commented 2 years ago

@toyobayashi 安装了。

屏幕截图 2022-01-20 164203

toyobayashi commented 2 years ago

@OleeHu

方便去 node_modules 里改一下这里,把错误贴上来吗?看上去是没找到 VS 的安装位置

https://github.com/toyobayashi/cgen/blob/8d2a8b969bc4bcf4dbaf9c273f7eb1b5bb391738/bin/util/cmake.js#L28-L37

if (err) {
  console.log(msvsver, err)
  return reject(err)
}
OleeHu commented 2 years ago

@toyobayashi

2022 Error: Could not find any Visual Studio installation to use
    at VisualStudioFinder.fail (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:131:47)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:84:16
    at VisualStudioFinder.findVisualStudio2013 (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:372:14)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:80:14
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:393:16
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:55:7
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:34:16
    at ChildProcess.exithandler (node:child_process:404:5)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
2019 Error: Could not find any Visual Studio installation to use
    at VisualStudioFinder.fail (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:131:47)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:84:16
    at VisualStudioFinder.findVisualStudio2013 (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:372:14)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:80:14
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:393:16
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:55:7
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:34:16
    at ChildProcess.exithandler (node:child_process:404:5)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
2017 Error: Could not find any Visual Studio installation to use
    at VisualStudioFinder.fail (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:131:47)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:84:16
    at VisualStudioFinder.findVisualStudio2013 (D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:372:14)
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:80:14
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\find-visualstudio.js:393:16
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:55:7
    at D:\Node\node_global\node_modules\@tybys\cgen\lib\util.js:34:16
    at ChildProcess.exithandler (node:child_process:404:5)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
Error: Visual Studio 2022/2019/2017 is not found
    at Object.getvsinfo (D:\Node\node_global\node_modules\@tybys\cgen\bin\util\cmake.js:51:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getTemplateData (D:\Node\node_global\node_modules\@tybys\cgen\bin\actions\init.js:76:14)
    at async InitAction.onExecute (D:\Node\node_global\node_modules\@tybys\cgen\bin\actions\init.js:49:18)
    at async DynamicCommandLineParser.onExecute (D:\Node\node_global\node_modules\@tybys\cgen\node_modules\@rushstack\ts-command-line\lib\providers\CommandLineParser.js:199:13)
Exit: 1

我改成了这样,你看对不对。

function findvs (msvsver) {
  return new Promise((resolve, reject) => {
    require('../../lib/find-visualstudio.js')({
      major: Number(process.versions.node.split('.')[0])
    }, msvsver, (err, info) => {
      if (err) { console.log(msvsver, err)
        return reject(err)}
      resolve(info)
    })
  })
}
toyobayashi commented 2 years ago

@OleeHu 你是刚装完 VS 吗?建议重启电脑试试。是 C# 脚本没找到 VS 的安装位置,这个 C# 找 VS 的实现是 node-gyp 仓库的。我本地也是 VS2022,没法重现这个问题

OleeHu commented 2 years ago

@toyobayashi 已经重启很多次了。

toyobayashi commented 2 years ago

@OleeHu 试试下面的命令,在 cmd 里按顺序敲,看能不能安装成功,如果失败了说明是你的VS环境问题

mkdir vstest
cd vstest
npm install -g node-gyp@8
for /f "delims=" %P in ('npm prefix -g') do npm config set node_gyp "%P\node_modules\node-gyp\bin\node-gyp.js"
npm install hca-decoder
OleeHu commented 2 years ago

@toyobayashi

C:\Windows\system32>mkdir vstest

C:\Windows\system32>cd vstest

C:\Windows\System32\vstest>npm install -g node-gyp@8

added 90 packages, and audited 91 packages in 7s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

C:\Windows\System32\vstest>for /f "delims=" %P in ('npm prefix -g') do npm config set node_gyp "%P\node_modules\node-gyp\bin\node-gyp.js"

C:\Windows\System32\vstest>npm config set node_gyp "D:\Node\node_global\node_modules\node-gyp\bin\node-gyp.js"

C:\Windows\System32\vstest>npm install hca-decoder
npm ERR! code 1
npm ERR! path C:\Windows\System32\node_modules\hca-decoder
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.2 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "D:\Anaconda\Anaconda3\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/win-x64/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/win-x86/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/win-x86/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/win-x64/node.lib
npm ERR! gyp http 404 https://nodejs.org/download/release/v16.13.2/win-arm64/node.lib
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack     at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at D:\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack     at D:\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at D:\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "D:\\Node\\node.exe" "D:\\Node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Windows\System32\node_modules\hca-decoder
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Node\node_cache\_logs\2022-01-20T09_49_49_205Z-debug-0.log

报错了

toyobayashi commented 2 years ago

@OleeHu 确定是你的 VS 有问题了,node-gyp 也找不到你的 VS 安装位置。建议重装 VS,用默认的安装位置

OleeHu commented 2 years ago

@toyobayashi 好的,谢谢

toyobayashi commented 2 years ago

@OleeHu 那 issue 我就先关闭了。如果重装VS还不行的话,可以留下你的联系方式,远程帮你看看