gpt4 book ai didi

node.js - Sqlite3、 Electron 、webpack : cannot find module abi_crosswalk. json

转载 作者:搜寻专家 更新时间:2023-10-31 23:47:03 25 4
gpt4 key购买 nike

我正在尝试让 sqlite3 结合 webpack、babel 和 react 在 electron 中工作。

这些是 package.json 中的依赖项:

"devDependencies": {
"babel-core": "^6.7.0",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"css-loader": "^0.23.1",
"electron-packager": "^5.2.1",
"electron-prebuilt": "^0.36.8",
"electron-rebuild": "^1.1.3",
"node-sass": "^3.4.2",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"webpack": "^1.12.14",
"webpack-dev-server": "1.14.0"
},
"dependencies": {
"sqlite3": "^3.1.1"
}

在运行 npm install 之后,我按照 documentation 中的描述运行了 ./node_modules/.bin/electron-rebuild .

这是我的 webpack.config.js:

var webpack = require('webpack');
module.exports = {
context: __dirname + '/src',
entry: './entry.js',
target: 'electron',

output: {
filename: 'bundle.js',
path: __dirname + '/build',
publicPath: 'http://localhost:8080/build/'
},

module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}, {
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}]
}
};

当我将 var sqlite3 = require('sqlite3').verbose(); 添加到我的代码并尝试运行它时,我将收到以下错误消息:

`Uncaught Error: Cannot find module "./abi_crosswalk.json"`

./~/sqlite3/~/node-pre-gyp/package.json
Module parse failed: .../node_modules/sqlite3/node_modules/node-pre-gyp/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
| "name": "node-pre-gyp",
| "description": "Node.js native addon binary install tool",
| "version": "0.6.14",
@ ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js 60:16-37

结果,找不到一堆模块。

谁能帮我解决这个问题?

编辑:这是导致评论中提到的 package.json 错误的 bundle.js 中的代码。

function(module, exports, __webpack_require__) {

"use strict";

var versioning = __webpack_require__(310);
var existsSync = __webpack_require__(19).existsSync || __webpack_require__(273).existsSync;
var path = __webpack_require__(273);

module.exports = exports;

exports.usage = 'Finds the require path for the node-pre-gyp installed module';

exports.validate = function(package_json) {
versioning.validate_config(package_json);
};

exports.find = function(package_json_path,opts) {
if (!existsSync(package_json_path)) {
throw new Error("package.json does not exist at " + package_json_path);
}
var package_json = __webpack_require__(1133)(package_json_path);
versioning.validate_config(package_json);
opts = opts || {};
if (!opts.module_root) opts.module_root = path.dirname(package_json_path);
var meta = versioning.evaluate(package_json,opts);
return meta.module;
};


/***/ },

最佳答案

似乎 var sqlite3 = require('sqlite3').verbose(); 只在主进程中有效,但在任何渲染进程中都无效。问题解决了。

关于node.js - Sqlite3、 Electron 、webpack : cannot find module abi_crosswalk. json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35915376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com