Node环境使用出现的问题
npm install的时候报错
报错信息:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve
依赖冲突 使用 npm install --legacy-peer-deps
Node环境安装better-sqlite3遇到的问题
shell
│ gyp info it worked if it ends with ok │ gyp info using node-gyp@9.4.1 │ gyp info using node@16.20.2 | win32 | x64 │ gyp ERR! find Python │ gyp ERR! find Python Python is not set from command line or npm configuration │ gyp ERR! find Python Python is not set from environment variable PYTHON │ gyp ERR! find Python checking if "python3" can be used │ gyp ERR! find Python - "python3" is not in PATH or produced an error │ gyp ERR! find Python checking if "python" can be used │ gyp ERR! find Python - "python" is not in PATH or produced an error │ gyp ERR! find Python checking if Python is C:\Users\lw\AppData\Local\Programs\Python\Python39\python.exe │ gyp ERR! find Python - "C:\Users\lw\AppData\Local\Programs\Python\Python39\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Program Files\Python39\python.exe │ gyp ERR! find Python - "C:\Program Files\Python39\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Users\lw\AppData\Local\Programs\Python\Python39-32\python.exe │ gyp ERR! find Python - "C:\Users\lw\AppData\Local\Programs\Python\Python39-32\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Program Files\Python39-32\python.exe │ gyp ERR! find Python - "C:\Program Files\Python39-32\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exe │ gyp ERR! find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Users\lw\AppData\Local\Programs\Python\Python38\python.exe │ gyp ERR! find Python - "C:\Users\lw\AppData\Local\Programs\Python\Python38\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Program Files\Python38\python.exe │ gyp ERR! find Python - "C:\Program Files\Python38\python.exe" could not be run │ gyp ERR! find Python checking if Python is C:\Users\lw\AppData\Local\Programs\Python\Python38-32\python.exe │ gyp ERR! find Python - "C:\Users\lw\AppData\Local\Programs\Python\Py这种情况是因为电脑中没有安装python,如果电脑上安装了,确认环境变量如果没有配置环境变量可以:
shell
npm config set python "C:\Path\To\python.exe"如果没有安装可以访问python安装最新稳定版本,better-sqlite3需要python3.0以上
安装最新版本再安装better-sqlite3 可能会出一下错误
shell
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@9.4.1
│ gyp info using node@16.20.2 | win32 | x64
│ gyp info find Python using Python version 3.12.4 found at "D:\Program Files\python\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 (D:\node\node_global\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
│ gyp ERR! stack at D:\node\node_global\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:75:16
│ gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\node\node_global\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
│ gyp ERR! stack at D:\node\node_global\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:71:14
│ gyp ERR! stack at D:\node\node_global\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:401:16
│ gyp ERR! stack at D:\node\node_global\node_modules\pnpm\dist\node_modules这个问题就是node版本的问题,我切换成node18之后就可一正常安装了
node环境中使用tensorflow/tfjs-node
运行的时候报错:
bash
Error: The specified module could not be found.
\\?\E:\mine\node-master\node-onnxruntime\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node
at Module._extensions..node (node:internal/modules/cjs/loader:1460:18)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (E:\mine\node-master\node-onnxruntime\node_modules\@tensorflow\tfjs-node\dist\index.js:72:16)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12) {
code: 'ERR_DLOPEN_FAILED'
}将E:\mine\node-master\node-onnxruntime\node_modules@tensorflow\tfjs-node\deps\lib\tensorflow.dll移到E:\mine\node-master\node-onnxruntime\node_modules@tensorflow\tfjs-node\lib\napi-v8\目录下即可