小编XEN*_*net的帖子

如何将 Socket.IO 与 NUXT 3 结合使用?

我想将 Socket.IO 与我的 Nuxt 3 应用程序一起使用,以便 Nuxt 应用程序和 Socket.IO 服务器共享相同的端口,并且一旦 Nuxt 应用程序准备就绪,Socket.IO 服务器就会自动启动。

\n

我探索了五种不同的解决方案,但它们都有各自的缺点:

\n

解决方案 1:使用nuxt-socket-io。在这里,自述文件提到了一种让模块与 Nuxt 3 和更新的 Socket.io 版本一起使用的解决方法,但是该解决方法会导致 404 页面,因为存储库的作者完全禁用了这些问题,并且似乎没有维护该模块不再有。

\n

TL; 博士:不起作用,没有支持。

\n

解决方案 2:使用nuxt3-socket.io这会产生错误。

\n

更新(2024 年 1 月):该模块目前似乎在开发和生产中都运行良好,并且非常易于使用。但是,我目前无法热重载(socket.io 服务器)来使用此解决方案,即使在修改文件时硝基会重新加载。我希望这个问题能够得到解决。

\n

这个问题表明存在潜在的兼容性问题,但我无法重现(在 macOS 上)。

\n

TL; dr:效果很好,易于使用,但没有(socket.io 服务器的)热重载,并且可能无法在每个平台上工作。(这是我目前首选的解决方案)

\n

解决方案 3: \n使用 Nuxt 中间件启动 Socket.io 服务器,如此处所述 \n此方法通常有效,但 Socket.io 服务器在请求“/ws”路由之前不会启动,因此需要额外的客户端代码。

\n

太棒了;通常可以工作,但 Socket.io 不会自动启动。

\n

解决方案 4: …

javascript socket.io typescript nuxtjs3 nuxt3

6
推荐指数
1
解决办法
3779
查看次数

无法使用 npm 安装 @tensorflow/tfjs-node

我无法安装“@tensorflow/tfjs-node”

我使用“npm install @tensorflow/tfjs-node”安装了它,但安装失败。我尝试在有和没有 root 权限的情况下全局安装“node-pre-gyp”,但没有成功。我在节点 v12.9.0 上运行。


> fsevents@1.2.9 install /Users/username/Documents/Development/AI/Tensorflow/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download 
[fsevents] Success: "/Users/username/Documents/Development/AI/Tensorflow/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" is installed via remote

> @tensorflow/tfjs-node@1.2.9 install /Users/username/Documents/Development/AI/Tensorflow/node_modules/@tensorflow/tfjs-node
> node scripts/install.js

CPU-darwin-1.2.9.tar.gz
* Downloading libtensorflow
[==============================] 10422374/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v4/1.2.9/CPU-darwin-1.2.9.tar.gz 
node-pre-gyp WARN Pre-built binaries not …
Run Code Online (Sandbox Code Playgroud)

node.js tensorflow node-pre-gyp

5
推荐指数
1
解决办法
3409
查看次数