我已经能够使用serialport运行node.js应用程序了。现在尝试将其移植到电子设备以进行跨平台使用。 'npm install serialport'产生了以下内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head>
<title>Dashboard</title>
<body>
<header>
<div class="logo"><a href="#">WORKOUT <span>FITNESS CENTER</span></a>
</div>
</header>
<div id="container">
<nav>
<ul>
<li><a href="#">Walk-In</a>
</li>
<li class="has-sub">
<a href="#" id='id1'>Members</a>
<ul>
<li><a href="#">Subscr</a>
</li>
<li><a href="#">asdasd</a>
</li>
<li><a href="#">asdasd</a>
</li>
</ul>
</li>
<li><a href="#">Sales</a>
</li>
<li><a href="#">Inventory</a>
</li>
<li><a href="#">Suppliers</a>
</li>
<li><a href="#">Reports</a>
</li>
</ul>
</nav>
<div id="content">
SOME CONTENT YAY
</div>
</div>
</body>
</html>
当我使用电子运行应用程序时,弹出窗口会抱怨
serialport@2.0.5 install /Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport
node-pre-gyp install --fallback-to-build
CXX(target) Release/obj.target/serialport/src/serialport.o
CXX(target) Release/obj.target/serialport/src/serialport_unix.o
CXX(target) Release/obj.target/serialport/src/serialport_poller.o
SOLINK_MODULE(target) Release/serialport.node
COPY /Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node
TOUCH Release/obj.target/action_after_build.stamp
electron-prebuilt@0.34.3 postinstall /Users/ylh/0/electron/electron-quick-start-master/node_modules/electron-prebuilt
node install.js
当然,node_modules目录中的版本是node-v47-darwin-x64。我不知道为什么npm install build v47但是找v46来运行。
答案 0 :(得分:3)
export npm_config_disturl=https://atom.io/download/atom-shell
export npm_config_target=0.34.3
export npm_config_arch=x64
export npm_config_runtime=electron
HOME=~/.electron-gyp npm install serialport
在此之后,转到/Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport/build/Release/
并将electron-0.34-darwin-x64
重命名为node-v46-darwin-x64