Closed mrgeneralgoo closed 9 months ago
需要更多的错误信息。
我的电脑就是 M1,可以正常工作的
我试着将它包装成一个 Raycast 插件,但是编译出错了,目前我暂时替换成了 pangu
。
import { getSelectedText } from "@raycast/api";
export default async function main() {
const selection = await getSelectedText();
// build failed (node_modules/autocorrect-node/index.js:38:36
// native bindings (e.g., .node files) are not supported because they are neither cross-platform nor cross-architecture;
const autocorrect = require('autocorrect-node');
return autocorrect.format(selection);
}
{
"dependencies": {
"@raycast/api": "^1.57.2",
"autocorrect-node": "^2.8.4"
}
}
这个可能是 raycast 里面的 Node.js 环境问题。
我猜 raycast 的运行环境可能是模拟的 Android 系统,所以被 Node.js 解析的时候理解为 Android 了。
autocorrect-node 里面获取 platform 是靠 process.platform
获取的。
https://github.com/huacnlee/autocorrect/blob/main/autocorrect-node/index.js#L10
另外 pangu 是无法做到 autocorrect 的特性的,可能简单的中英文空格是可以的。
autocorrect 可以支持各类复杂的文件类型,处理细节更深入
你可以试试集成 Wasm 版本的,VS Code 插件里面用的就是这个。
https://www.npmjs.com/package/@huacnlee/autocorrect
autocorrect-node 反而是为了支持完整的 autocorrect bin 的功能,例如遍历文件,lint,结果输出等等完整功能(当然作为一个基础的 format
功能也是支持的)。
感谢答复,我换成 Wasm 版本试一下
两者的兼容性似乎很差,sad...
TypeError: wasm.__wbindgen_add_to_stack_pointer is not a function
at format (/path/index.js:404:10)
at Object.main (/path/index:423:36)
import { getSelectedText } from "@raycast/api";
import { format } from "@huacnlee/autocorrect";
export default async function main() {
const selection = await getSelectedText();
return format(selection);
}
暂不解决此问题
build failed (node_modules/autocorrect-node/index.js:38:36 nativeBinding = require('./autocorrect-node.android-arm64.node')): native bindings (e.g., .node files) are not supported because they are neither cross-platform nor cross-architecture; for example, native bindings built on a M1 mac would not work on an Intel Mac
MacBook Pro M1 13.5