我正在尝试在电子应用程序中使用socket.io并且我一直在使用电子伪造来构建和打包。
以下输出是从名为tester的vanilla electronic-init应用程序运行electron-forge启动的结果,通过npm安装了socket.io。
An unhandled error has occurred inside Forge:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@7.5.0 | darwin | x64
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/Users/jamiehudson/.nvm/versions/node/v7.5.0/lib/node_modules/electron-forge/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamiehudson/dev/electronStuff/tester/node_modules/uws/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamiehudson/.nvm/versions/node/v7.5.0/lib/node_modules/electron-forge/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/jamiehudson/.electron-gyp/.node-gyp/iojs-1.6.11/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/jamiehudson/.electron-gyp/.node-gyp/iojs-1.6.11',
gyp info spawn args '-Dnode_gyp_dir=/Users/jamiehudson/.nvm/versions/node/v7.5.0/lib/node_modules/electron-forge/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/jamiehudson/.electron-gyp/.node-gyp/iojs-1.6.11/<(target_arch)/iojs.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/jamiehudson/dev/electronStuff/tester/node_modules/uws',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/uws/src/Extensions.o
CXX(target) Release/obj.target/uws/src/Group.o
In file included from ../src/Group.cpp:1:
In file included from ../src/Group.h:4:
In file included from ../src/WebSocket.h:4:
In file included from ../src/WebSocketProtocol.h:5:
../src/Networking.h:7:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
^
1 error generated.
make: *** [Release/obj.target/uws/src/Group.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/jamiehudson/.nvm/versions/node/v7.5.0/lib/node_modules/electron-forge/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:192:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.5.0
gyp ERR! command "/Users/jamiehudson/.nvm/versions/node/v7.5.0/bin/node" "/Users/jamiehudson/.nvm/versions/node/v7.5.0/lib/node_modules/electron-forge/node_modules/.bin/node-gyp" "rebuild" "--target=1.6.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source"
gyp ERR! cwd /Users/jamiehudson/dev/electronStuff/tester/node_modules/uws
gyp ERR! node -v v7.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
我已将brew的最新版openssl链接起来:
openssl version
OpenSSL 1.0.2l 25 May 2017
的package.json:
{
"name": "tester",
"productName": "tester",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"lint": "eslint src"
},
"keywords": [],
"author": "jamiehudson",
"license": "MIT",
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {},
"electronWinstallerConfig": {
"name": "tester"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "",
"name": ""
},
"windowsStoreConfig": {
"packageName": "",
"name": "tester"
}
}
},
"dependencies": {
"electron-compile": "^6.4.1",
"socket.io": "^2.0.3"
},
"devDependencies": {
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"electron-prebuilt-compile": "1.6.11",
"eslint": "^4.2.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0"
}
}
节点版本:
v7.5.0
Mac OS版本:
Sierra 10.12.4
我在Ubuntu上遇到了同样的问题,但在安装了libssl-dev之后,问题得到了纠正。
是否可能是node-gyp问题+ python +一些openssl问题?
答案 0 :(得分:1)
这只是openssl的问题,需要符号链接brew安装并添加CPPFLAGS和LDFLAGS环境变量:
CPPFLAGS = -I的/ usr /本地的/ opt / OpenSSL的/包括 LDFLAGS = -L / USR /本地的/ opt / OpenSSL的/ lib中
uws现在建立正常
答案 1 :(得分:-2)
嘿所以我和你有类似的问题。我在我的项目中使用Socket.io并且在尝试运行electron-forge package
时遇到了与您相同的错误。为了使它正常工作,我从package.json中删除了依赖项"socket.io": "^2.0.3"
,然后我就可以无问题地打包它。希望它有所帮助!