这里是Node / Vue.js的新手,所以我可能做的完全是愚蠢的,没什么事-
let expect = expectation(description: "Async network call")
SomeManager.executeCall { result in
XCTAssertThrowsError({try CoreManager.method()}, "The method didn't throw")
expect.fulfill()
}
waitForExpectations(timeout: 15.0, handler: nil)
// package.json
{
"name": "simple-addon",
"version": "1.0.0",
"description": "",
"main": "index.js",
"gypfile": true,
"scripts": {
"build": "node-gyp rebuild",
"clean": "node-gyp clean"
},
"files": [
"src/*.cpp",
"src/*.hpp",
"binding.gyp"
],
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^5.16.0",
"node-gyp": "^4.0.0"
},
"dependencies": {
"node-addon-api": "^1.6.3"
}
}
使用node-gyp进行构建很好,作为健全性检查,我可以通过在新目录中执行// index.js
const simpleaddon = require('./build/Release/simple-addon.node');
module.exports = simpleaddon;
,npm init
在示例节点应用程序中导入和使用它。 / p>
我无法简单地导入它(由于原因,我仍然无法完全理解,抱歉),我不得不使用另一个加载器:native-ext-loader。否则我会得到npm install ../simpleaddon
配置加载程序:
Module parse failed: Unexpected character '' (1:0) You may need an appropriate loader to handle this file type.
这可以解决问题,但是当我尝试使用// vue.config.js
module.exports = {
chainWebpack: config => {
config.module
.rule('native')
.test(/\.node$/)
.use('native-ext-loader')
.loader('native-ext-loader')
}
}
导入组件时
我得到:
import simpleaddon from "simple-addon";
我想念什么?