这是我的第一个Electron项目,使用入门后,抱歉,如果它太笨了
我正在尝试使我所做的某些事情自动化,因此我的第一个项目应该是带有此lib的东西: http://robotjs.io/
但是我收到此错误:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/flyahed/electron/zezeta/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/flyahed/electron/zezeta/node_modules/robotjs/index.js:1:170)
at Object.<anonymous> (/home/flyahed/electron/zezeta/node_modules/robotjs/index.js:38:3)
我做了什么: npm安装robotjs
rm -r node_modules和npm install (在Internet上搜索,我发现这可能是问题的解决方法)
将此行添加到我的package.json中,来自:(http://robotjs.io/docs/electron)
"main": "index.js",
"scripts": {
"rebuild": "npm rebuild --runtime=electron --target=1.1.3 --disturl=https://atom.io/download/atom-shell --abi=48",
"electron": "electron ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^3.0.7"
},
"dependencies": {
"robotjs": "^0.5.1"
}
npm运行重建 npm运行电子
但错误仍然显示
完整命令日志:
flyahed@flyahed:~/electron/autothis$ ls
index.html index.js package.json package-lock.json
flyahed@flyahed:~/electron/autothis$ npm install
> robotjs@0.5.1 install /home/flyahed/electron/autothis/node_modules/robotjs
> prebuild-install || node-gyp rebuild
> electron@3.0.7 postinstall /home/flyahed/electron/autothis/node_modules/electron
> node install.js
npm WARN autothis@1.0.0 No description
npm WARN autothis@1.0.0 No repository field.
added 191 packages from 148 contributors and audited 308 packages in 3.329s
found 0 vulnerabilities
flyahed@flyahed:~/electron/autothis$ npm run rebuild
> autothis@1.0.0 rebuild /home/flyahed/electron/autothis
> npm rebuild --runtime=electron --target=1.1.3 --disturl=https://atom.io/download/atom-shell --abi=48
> robotjs@0.5.1 install /home/flyahed/electron/autothis/node_modules/robotjs
> prebuild-install || node-gyp rebuild
> electron@3.0.7 postinstall /home/flyahed/electron/autothis/node_modules/electron
> node install.js
robotjs@0.5.1 /home/flyahed/electron/autothis/node_modules/robotjs
nan@2.11.1 /home/flyahed/electron/autothis/node_modules/nan
prebuild-install@2.5.3 /home/flyahed/electron/autothis/node_modules/prebuild-install
detect-libc@1.0.3 /home/flyahed/electron/autothis/node_modules/detect-libc
expand-template@1.1.1 /home/flyahed/electron/autothis/node_modules/expand-template
github-from-package@0.0.0 /home/flyahed/electron/autothis/node_modules/github-from-package
minimist@1.2.0 /home/flyahed/electron/autothis/node_modules/minimist
mkdirp@0.5.1 /home/flyahed/electron/autothis/node_modules/mkdirp
minimist@0.0.8 /home/flyahed/electron/autothis/node_modules/mkdirp/node_modules/minimist
node-abi@2.5.0 /home/flyahed/electron/autothis/node_modules/node-abi
semver@5.6.0 /home/flyahed/electron/autothis/node_modules/semver
noop-logger@0.1.1 /home/flyahed/electron/autothis/node_modules/noop-logger
npmlog@4.1.2 /home/flyahed/electron/autothis/node_modules/npmlog
are-we-there-yet@1.1.5 /home/flyahed/electron/autothis/node_modules/are-we-there-yet
delegates@1.0.0 /home/flyahed/electron/autothis/node_modules/delegates
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/readable-stream
core-util-is@1.0.2 /home/flyahed/electron/autothis/node_modules/core-util-is
inherits@2.0.3 /home/flyahed/electron/autothis/node_modules/inherits
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/isarray
process-nextick-args@2.0.0 /home/flyahed/electron/autothis/node_modules/process-nextick-args
safe-buffer@5.1.2 /home/flyahed/electron/autothis/node_modules/safe-buffer
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/are-we-there-yet/node_modules/string_decoder
util-deprecate@1.0.2 /home/flyahed/electron/autothis/node_modules/util-deprecate
console-control-strings@1.1.0 /home/flyahed/electron/autothis/node_modules/console-control-strings
gauge@2.7.4 /home/flyahed/electron/autothis/node_modules/gauge
aproba@1.2.0 /home/flyahed/electron/autothis/node_modules/aproba
has-unicode@2.0.1 /home/flyahed/electron/autothis/node_modules/has-unicode
object-assign@4.1.1 /home/flyahed/electron/autothis/node_modules/object-assign
signal-exit@3.0.2 /home/flyahed/electron/autothis/node_modules/signal-exit
string-width@1.0.2 /home/flyahed/electron/autothis/node_modules/string-width
code-point-at@1.1.0 /home/flyahed/electron/autothis/node_modules/code-point-at
is-fullwidth-code-point@1.0.0 /home/flyahed/electron/autothis/node_modules/is-fullwidth-code-point
number-is-nan@1.0.1 /home/flyahed/electron/autothis/node_modules/number-is-nan
strip-ansi@3.0.1 /home/flyahed/electron/autothis/node_modules/strip-ansi
ansi-regex@2.1.1 /home/flyahed/electron/autothis/node_modules/ansi-regex
wide-align@1.1.3 /home/flyahed/electron/autothis/node_modules/wide-align
set-blocking@2.0.0 /home/flyahed/electron/autothis/node_modules/set-blocking
os-homedir@1.0.2 /home/flyahed/electron/autothis/node_modules/os-homedir
pump@2.0.1 /home/flyahed/electron/autothis/node_modules/pump
end-of-stream@1.4.1 /home/flyahed/electron/autothis/node_modules/end-of-stream
once@1.4.0 /home/flyahed/electron/autothis/node_modules/once
wrappy@1.0.2 /home/flyahed/electron/autothis/node_modules/wrappy
rc@1.2.8 /home/flyahed/electron/autothis/node_modules/rc
deep-extend@0.6.0 /home/flyahed/electron/autothis/node_modules/deep-extend
ini@1.3.5 /home/flyahed/electron/autothis/node_modules/ini
strip-json-comments@2.0.1 /home/flyahed/electron/autothis/node_modules/strip-json-comments
simple-get@2.8.1 /home/flyahed/electron/autothis/node_modules/simple-get
decompress-response@3.3.0 /home/flyahed/electron/autothis/node_modules/decompress-response
mimic-response@1.0.1 /home/flyahed/electron/autothis/node_modules/mimic-response
simple-concat@1.0.0 /home/flyahed/electron/autothis/node_modules/simple-concat
tar-fs@1.16.3 /home/flyahed/electron/autothis/node_modules/tar-fs
chownr@1.1.1 /home/flyahed/electron/autothis/node_modules/chownr
pump@1.0.3 /home/flyahed/electron/autothis/node_modules/tar-fs/node_modules/pump
tar-stream@1.6.2 /home/flyahed/electron/autothis/node_modules/tar-stream
bl@1.2.2 /home/flyahed/electron/autothis/node_modules/bl
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/bl/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/bl/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/bl/node_modules/string_decoder
buffer-alloc@1.2.0 /home/flyahed/electron/autothis/node_modules/buffer-alloc
buffer-alloc-unsafe@1.1.0 /home/flyahed/electron/autothis/node_modules/buffer-alloc-unsafe
buffer-fill@1.0.0 /home/flyahed/electron/autothis/node_modules/buffer-fill
fs-constants@1.0.0 /home/flyahed/electron/autothis/node_modules/fs-constants
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/string_decoder
to-buffer@1.1.1 /home/flyahed/electron/autothis/node_modules/to-buffer
xtend@4.0.1 /home/flyahed/electron/autothis/node_modules/tar-stream/node_modules/xtend
tunnel-agent@0.6.0 /home/flyahed/electron/autothis/node_modules/tunnel-agent
which-pm-runs@1.0.0 /home/flyahed/electron/autothis/node_modules/which-pm-runs
@types/node@8.10.37 /home/flyahed/electron/autothis/node_modules/@types/node
ajv@5.5.2 /home/flyahed/electron/autothis/node_modules/ajv
co@4.6.0 /home/flyahed/electron/autothis/node_modules/co
fast-deep-equal@1.1.0 /home/flyahed/electron/autothis/node_modules/fast-deep-equal
fast-json-stable-stringify@2.0.0 /home/flyahed/electron/autothis/node_modules/fast-json-stable-stringify
json-schema-traverse@0.3.1 /home/flyahed/electron/autothis/node_modules/json-schema-traverse
array-find-index@1.0.2 /home/flyahed/electron/autothis/node_modules/array-find-index
asn1@0.2.4 /home/flyahed/electron/autothis/node_modules/asn1
safer-buffer@2.1.2 /home/flyahed/electron/autothis/node_modules/safer-buffer
assert-plus@1.0.0 /home/flyahed/electron/autothis/node_modules/assert-plus
asynckit@0.4.0 /home/flyahed/electron/autothis/node_modules/asynckit
aws-sign2@0.7.0 /home/flyahed/electron/autothis/node_modules/aws-sign2
aws4@1.8.0 /home/flyahed/electron/autothis/node_modules/aws4
bcrypt-pbkdf@1.0.2 /home/flyahed/electron/autothis/node_modules/bcrypt-pbkdf
tweetnacl@0.14.5 /home/flyahed/electron/autothis/node_modules/tweetnacl
buffer-from@1.1.1 /home/flyahed/electron/autothis/node_modules/buffer-from
builtin-modules@1.1.1 /home/flyahed/electron/autothis/node_modules/builtin-modules
camelcase@2.1.1 /home/flyahed/electron/autothis/node_modules/camelcase
camelcase-keys@2.1.0 /home/flyahed/electron/autothis/node_modules/camelcase-keys
map-obj@1.0.1 /home/flyahed/electron/autothis/node_modules/map-obj
caseless@0.12.0 /home/flyahed/electron/autothis/node_modules/caseless
combined-stream@1.0.7 /home/flyahed/electron/autothis/node_modules/combined-stream
delayed-stream@1.0.0 /home/flyahed/electron/autothis/node_modules/delayed-stream
currently-unhandled@0.4.1 /home/flyahed/electron/autothis/node_modules/currently-unhandled
dashdash@1.14.1 /home/flyahed/electron/autothis/node_modules/dashdash
debug@3.2.6 /home/flyahed/electron/autothis/node_modules/debug
ms@2.1.1 /home/flyahed/electron/autothis/node_modules/ms
decamelize@1.2.0 /home/flyahed/electron/autothis/node_modules/decamelize
ecc-jsbn@0.1.2 /home/flyahed/electron/autothis/node_modules/ecc-jsbn
jsbn@0.1.1 /home/flyahed/electron/autothis/node_modules/jsbn
env-paths@1.0.0 /home/flyahed/electron/autothis/node_modules/env-paths
error-ex@1.3.2 /home/flyahed/electron/autothis/node_modules/error-ex
is-arrayish@0.2.1 /home/flyahed/electron/autothis/node_modules/is-arrayish
extend@3.0.2 /home/flyahed/electron/autothis/node_modules/extend
extsprintf@1.3.0 /home/flyahed/electron/autothis/node_modules/extsprintf
fd-slicer@1.0.1 /home/flyahed/electron/autothis/node_modules/fd-slicer
pend@1.2.0 /home/flyahed/electron/autothis/node_modules/pend
forever-agent@0.6.1 /home/flyahed/electron/autothis/node_modules/forever-agent
form-data@2.3.3 /home/flyahed/electron/autothis/node_modules/form-data
mime-types@2.1.21 /home/flyahed/electron/autothis/node_modules/mime-types
mime-db@1.37.0 /home/flyahed/electron/autothis/node_modules/mime-db
fs-extra@4.0.3 /home/flyahed/electron/autothis/node_modules/fs-extra
graceful-fs@4.1.11 /home/flyahed/electron/autothis/node_modules/graceful-fs
jsonfile@4.0.0 /home/flyahed/electron/autothis/node_modules/jsonfile
universalify@0.1.2 /home/flyahed/electron/autothis/node_modules/universalify
get-stdin@4.0.1 /home/flyahed/electron/autothis/node_modules/get-stdin
getpass@0.1.7 /home/flyahed/electron/autothis/node_modules/getpass
har-schema@2.0.0 /home/flyahed/electron/autothis/node_modules/har-schema
har-validator@5.1.0 /home/flyahed/electron/autothis/node_modules/har-validator
hosted-git-info@2.7.1 /home/flyahed/electron/autothis/node_modules/hosted-git-info
http-signature@1.2.0 /home/flyahed/electron/autothis/node_modules/http-signature
jsprim@1.4.1 /home/flyahed/electron/autothis/node_modules/jsprim
json-schema@0.2.3 /home/flyahed/electron/autothis/node_modules/json-schema
verror@1.10.0 /home/flyahed/electron/autothis/node_modules/verror
sshpk@1.15.2 /home/flyahed/electron/autothis/node_modules/sshpk
indent-string@2.1.0 /home/flyahed/electron/autothis/node_modules/indent-string
repeating@2.0.1 /home/flyahed/electron/autothis/node_modules/repeating
is-finite@1.0.2 /home/flyahed/electron/autothis/node_modules/is-finite
is-builtin-module@1.0.0 /home/flyahed/electron/autothis/node_modules/is-builtin-module
is-typedarray@1.0.0 /home/flyahed/electron/autothis/node_modules/is-typedarray
is-utf8@0.2.1 /home/flyahed/electron/autothis/node_modules/is-utf8
isarray@0.0.1 /home/flyahed/electron/autothis/node_modules/isarray
isstream@0.1.2 /home/flyahed/electron/autothis/node_modules/isstream
json-stringify-safe@5.0.1 /home/flyahed/electron/autothis/node_modules/json-stringify-safe
load-json-file@1.1.0 /home/flyahed/electron/autothis/node_modules/load-json-file
parse-json@2.2.0 /home/flyahed/electron/autothis/node_modules/parse-json
pify@2.3.0 /home/flyahed/electron/autothis/node_modules/pify
pinkie-promise@2.0.1 /home/flyahed/electron/autothis/node_modules/pinkie-promise
pinkie@2.0.4 /home/flyahed/electron/autothis/node_modules/pinkie
strip-bom@2.0.0 /home/flyahed/electron/autothis/node_modules/strip-bom
loud-rejection@1.6.0 /home/flyahed/electron/autothis/node_modules/loud-rejection
meow@3.7.0 /home/flyahed/electron/autothis/node_modules/meow
normalize-package-data@2.4.0 /home/flyahed/electron/autothis/node_modules/normalize-package-data
validate-npm-package-license@3.0.4 /home/flyahed/electron/autothis/node_modules/validate-npm-package-license
spdx-correct@3.0.2 /home/flyahed/electron/autothis/node_modules/spdx-correct
spdx-expression-parse@3.0.0 /home/flyahed/electron/autothis/node_modules/spdx-expression-parse
spdx-exceptions@2.2.0 /home/flyahed/electron/autothis/node_modules/spdx-exceptions
spdx-license-ids@3.0.2 /home/flyahed/electron/autothis/node_modules/spdx-license-ids
read-pkg-up@1.0.1 /home/flyahed/electron/autothis/node_modules/read-pkg-up
find-up@1.1.2 /home/flyahed/electron/autothis/node_modules/find-up
path-exists@2.1.0 /home/flyahed/electron/autothis/node_modules/find-up/node_modules/path-exists
read-pkg@1.1.0 /home/flyahed/electron/autothis/node_modules/read-pkg
path-type@1.1.0 /home/flyahed/electron/autothis/node_modules/path-type
redent@1.0.0 /home/flyahed/electron/autothis/node_modules/redent
strip-indent@1.0.1 /home/flyahed/electron/autothis/node_modules/strip-indent
trim-newlines@1.0.0 /home/flyahed/electron/autothis/node_modules/trim-newlines
oauth-sign@0.9.0 /home/flyahed/electron/autothis/node_modules/oauth-sign
object-keys@0.4.0 /home/flyahed/electron/autothis/node_modules/object-keys
path-exists@3.0.0 /home/flyahed/electron/autothis/node_modules/path-exists
performance-now@2.1.0 /home/flyahed/electron/autothis/node_modules/performance-now
psl@1.1.29 /home/flyahed/electron/autothis/node_modules/psl
progress-stream@1.2.0 /home/flyahed/electron/autothis/node_modules/progress-stream
speedometer@0.1.4 /home/flyahed/electron/autothis/node_modules/speedometer
through2@0.2.3 /home/flyahed/electron/autothis/node_modules/through2
readable-stream@1.1.14 /home/flyahed/electron/autothis/node_modules/readable-stream
string_decoder@0.10.31 /home/flyahed/electron/autothis/node_modules/string_decoder
xtend@2.1.2 /home/flyahed/electron/autothis/node_modules/xtend
punycode@1.4.1 /home/flyahed/electron/autothis/node_modules/punycode
qs@6.5.2 /home/flyahed/electron/autothis/node_modules/qs
request@2.88.0 /home/flyahed/electron/autothis/node_modules/request
tough-cookie@2.4.3 /home/flyahed/electron/autothis/node_modules/tough-cookie
uuid@3.3.2 /home/flyahed/electron/autothis/node_modules/uuid
single-line-log@1.1.2 /home/flyahed/electron/autothis/node_modules/single-line-log
throttleit@0.0.2 /home/flyahed/electron/autothis/node_modules/throttleit
typedarray@0.0.6 /home/flyahed/electron/autothis/node_modules/typedarray
yauzl@2.4.1 /home/flyahed/electron/autothis/node_modules/yauzl
electron@3.0.7 /home/flyahed/electron/autothis/node_modules/electron
electron-download@4.1.1 /home/flyahed/electron/autothis/node_modules/electron-download
nugget@2.0.1 /home/flyahed/electron/autothis/node_modules/nugget
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/nugget/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/nugget/node_modules/ms
pretty-bytes@1.0.4 /home/flyahed/electron/autothis/node_modules/pretty-bytes
sumchecker@2.0.2 /home/flyahed/electron/autothis/node_modules/sumchecker
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/sumchecker/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/sumchecker/node_modules/ms
extract-zip@1.6.7 /home/flyahed/electron/autothis/node_modules/extract-zip
concat-stream@1.6.2 /home/flyahed/electron/autothis/node_modules/concat-stream
readable-stream@2.3.6 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/readable-stream
isarray@1.0.0 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/isarray
string_decoder@1.1.1 /home/flyahed/electron/autothis/node_modules/concat-stream/node_modules/string_decoder
debug@2.6.9 /home/flyahed/electron/autothis/node_modules/extract-zip/node_modules/debug
ms@2.0.0 /home/flyahed/electron/autothis/node_modules/extract-zip/node_modules/ms
flyahed@flyahed:~/electron/autothis$ npm run electron
> autothis@1.0.0 electron /home/flyahed/electron/autothis
> electron .
App threw an error during load
Error: The module '/home/flyahed/electron/autothis/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:1:170)
at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:38:3)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/flyahed/electron/autothis/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:1:170)
at Object.<anonymous> (/home/flyahed/electron/autothis/node_modules/robotjs/index.js:38:3)