我正在构建一个需要使用串口的Atom插件
我npm install --save serialport
它似乎有效,但是当我在Windows 10机器上运行时,我收到了下面列出的错误#1。
如果我删除node_modules/serialport
目录并执行apm install
我收到错误#2,这是一个节点pre-gyn编译错误。
npm
和apm
之间存在差异?Error: %1 is not a valid Win32 application.
\\?\C:\Users\idoran\github\arduino\node_modules\serialport\build\Release\serialport.node
at Error (native)
at process.module.(anonymous function) (ELECTRON_ASAR.js:158:20)
at process.module.(anonymous function) (ELECTRON_ASAR.js:158:20)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:158:20)
at Object.Module._extensions..node (module.js:440:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:158:20)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:50:27)
at bindings (C:\Users\idoran\github\arduino\node_modules\bindings\bindings.js:76:44)
at Object.<anonymous> (C:\Users\idoran\github\arduino\node_modules\serialport\lib\bindings.js:3:35)
at Module._compile (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .js] (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:50:27)
at Object.<anonymous> (C:\Users\idoran\github\arduino\node_modules\serialport\lib\serialport.js:12:25)
at Module._compile (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .js] (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:50:27)
at Object.<anonymous> (C:\Users\idoran\github\arduino\lib\master.js:9:10)
at Module._compile (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\native-compile-cache.js:103:30)
at Object.defineProperty.value [as .js] (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app.asar\src\compile-cache.js:208:21)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
Installing modules failed
> serialport@4.0.1 install C:\Users\idoran\github\arduino\node_modules\serialport
> node-pre-gyp install --fallback-to-build
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [C:\Users\idoran\github\arduino\node_modules\serialport\build\serialport.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified. [C:\Users\idoran\github\arduino\node_modules\serialport\build\serialport.vcxproj]
Failed to execute 'C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app\apm\bin\node.exe C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app\apm\bin\\..\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\idoran\github\arduino\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\idoran\github\arduino\node_modules\serialport\build\Release' (1)
node-pre-gyp ERR! Tried to download: https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.1/serialport-v4.0.1-electron-v0.37-win32-ia32.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.1 and electron@0.37.8 (electron-v0.37 ABI) (falling back to source compile with node-gyp)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app\apm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Users\\idoran\\AppData\\Local\\atom\\app-1.10.0\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\idoran\\AppData\\Local\\atom\\app-1.10.0\\resources\\app\\apm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\idoran\\github\\arduino\\node_modules\\serialport\\build\\Release\\serialport.node" "--module_name=serialport" "--module_path=C:\\Users\\idoran\\github\\arduino\\node_modules\\serialport\\build\\Release"
gyp ERR! cwd C:\Users\idoran\github\arduino\node_modules\serialport
gyp ERR! node -v v4.4.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app\apm\bin\node.exe C:\Users\idoran\AppData\Local\atom\app-1.10.0\resources\app\apm\bin\\..\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\idoran\github\arduino\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=C:\Users\idoran\github\arduino\node_modules\serialport\build\Release' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\idoran\github\arduino\node_modules\serialport\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:827:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Windows_NT 10.0.10586
node-pre-gyp ERR! command "C:\\Users\\idoran\\AppData\\Local\\atom\\app-1.10.0\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\idoran\\github\\arduino\\node_modules\\serialport\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\idoran\github\arduino\node_modules\serialport
node-pre-gyp ERR! node -v v4.4.5
node-pre-gyp ERR! node-pre-gyp -v v0.6.29
node-pre-gyp ERR! not ok
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Users\\idoran\\AppData\\Local\\atom\\app-1.10.0\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\idoran\\AppData\\Local\\atom\\app-1.10.0\\resources\\app\\apm\\node_modules\\npm\\bin\\npm-cli.js" "--globalconfig" "C:\\Users\\idoran\\.atom\\.apm\\.apmrc" "--userconfig" "C:\\Users\\idoran\\.atom\\.apmrc" "install" "--runtime=electron" "--target=0.37.8" "--arch=ia32" "--msvs_version=2015"
npm ERR! node v4.4.5
npm ERR! npm v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! serialport@4.0.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.1 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\idoran\github\arduino\npm-debug.log
答案 0 :(得分:1)
您可以使用electron-rebuild构建具有特定节点/ Atom版本的本机模块。这将确保模块在Atom期望它找到的位置构建和安装。
我使用这种方法在Electron项目中使用node-serialport。
编辑:
电子重建取决于VC ++编译器(cl.exe)的可用性。确保已安装cl.exe并且该路径已在路径上。 Visual Studio默认不安装c ++,因此在安装过程中选择vc ++作为选项。