当前位置: 移动技术网 > IT编程>开发语言>JavaScript > Electron npm install 常见错误(Linux)

Electron npm install 常见错误(Linux)

2019年08月04日  | 移动技术网IT编程  | 我要评论

linux版本

ubuntu 12.04 (32bit)

安装git

sudo apt-get install git

生成ssh key

#查看有没有sshkey
cd ~/.ssh
#生成
ssh-keygen
#查询
cat ~/.ssh/id_rsa.pub

安装node

使用二进制文件

错误一:./node: cannot execute binary file

原因可能如下:

1、非root用户或者无执行权限

2、编译环境不同(程序由其他操作环境复制过来)

ps:

错误二:axconfig: port 1 not active axconfig: port 2 not active

原因:可能 sudo apt-get install node 这么去安装node了。

解决:先 sudo apt-get remove node 卸载掉,从node官网下。

ps:

编译源码

错误一:warning: failed to autodetect c++ compiler version (cxx=g++)

error: did not find a new enough assembler, install one or build with

       --openssl-no-asm.

       please refer to building.md

ps:因为安装过程复制且不顺利,就不走这条路。

低版本的node

ps:node 10.10以上版本,ubuntu 12.04一直无法正常使用,所以我用了8版本。

安装步骤:

建立软连接:

sudo ln -s /home/lufeng/documents/node-v8.16.0-linux-x86/bin/node /usr/local/bin
sudo ln -s /home/lufeng/documents/node-v8.16.0-linux-x86/bin/npm /usr/local/bin
sudo ln -s /home/lufeng/documents/node-v8.16.0-linux-x86/bin/node-gyp /usr/local/bin

electron npm install

错误一: ../../../nan/nan.h:50:3: error: #error this version of node/nan/v8 requires a c++11 compiler

解决:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

错误二:make: cc: command not found

解决:

sudo ln -s  /usr/bin/gcc-4.9 /usr/bin/cc

错误三:/usr/bin/ld: cannot find -lcrypto

下载一个libcrypto.so.6 文件

sudo ln -s /home/lufeng/documents/lib/libcrypto.so.6 /lib/libcrypto.so

错误四:error: 'memcpy' was not declared in this scope

原因:node插件源码报错了,其实解决办法很容易,到程序中加上头文件string.h就好了,就是 #include<string.h>

electron rebuild

错误一:fatal error openssl/rand.h no such file or directory

解决:安装libssl-dev。

sudo apt-get install libssl-dev

可能libssl-dev会安装失败

sudo apt-get install libssl-dev=1.0.1-4ubuntu5

解决: (方法一)

错误二:error while loading shared libraries: libxss.so.1: cannot open shared object file: no such file or directory

解决:

sudo apt-get install libxss1

错误三:error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: no such file or directory

暂时无解:一直install 不了libatk-bridge2.0-0这个依赖,总是报未找到匹配软件包!!!

总结

electron rebuild到上面最后的一个错,就走不下去了,那个缺失的库始终无法安装,也就是ubuntu 12.04 上运行electron宣告失败。

ubuntu12.04 试了两天,太心累了,系统缺失的库太多了且有装不上的。

最后,我更换ubuntu16.04 做尝试,却很快成功跑起electron。它仅仅缺失一个库,上面大部分错误都没有出现。不过要注意node使用10版本、gcc使用4.9就行了,使用node 12、gcc 5都会报错的。 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网