如何在 NodeJS 中手动安装全局模块
How to manually install a global module in NodeJS
出于某种原因,我正在尝试在我的计算机上手动安装串口模块。我尝试复制 github 文件,然后将其粘贴到 roam 文件夹中,但后来我 运行 进入以下问题。
└─┬ serialport@4.0.1
├── UNMET DEPENDENCY bindings@1.2.1
├── UNMET DEPENDENCY commander@^2.9.0
├── UNMET DEPENDENCY debug@^2.1.1
├── UNMET DEPENDENCY lie@^3.1.0
├── UNMET DEPENDENCY nan@^2.3.5
├── UNMET DEPENDENCY node-pre-gyp@^0.6.26
└── UNMET DEPENDENCY object.assign@^4.0.3
npm ERR! missing: bindings@1.2.1, required by serialport@4.0.1
npm ERR! missing: commander@^2.9.0, required by serialport@4.0.1
npm ERR! missing: debug@^2.1.1, required by serialport@4.0.1
npm ERR! missing: lie@^3.1.0, required by serialport@4.0.1
npm ERR! missing: nan@^2.3.5, required by serialport@4.0.1
npm ERR! missing: node-pre-gyp@^0.6.26, required by serialport@4.0.1
npm ERR! missing: object.assign@^4.0.3, required by serialport@4.0.1
我正在尝试从 windows 命令提示符 运行 serialport-list
。串口的原因。
当我通常以正常方式尝试串行端口时,我 运行 出现以下错误:
vcbuild.exe : error VCBLD0010: Project 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.
vcproj' requires upgrade. Use 'vcbuild /upgrade' or 'devenv /upgrade' to upgrade the project. [C:\Users\Jonathan\AppDat
a\Roaming\npm\node_modules\serialport\build\binding.sln]
我无法应用升级,因为该文件不存在,所以我手动下载了 serialport.vcproj 文件并应用了升级,然后复制了串口节点模块,但仍然无法 运行 serialport-list
关闭命令提示符。
更新
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>vcbuild /upgrade C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.vcproj
Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.30729
Copyright (C) Microsoft Corporation. All rights reserved.
Successfully upgraded project file 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.vcproj'.
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>npm install
> serialport@4.0.1 install C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download: https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.1/serialport-v4.0.1-node-v44-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.1 and node@2.2.1 (node-v44 ABI) (falling back to source compile with node-gyp)
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node clean )
gyp ERR! clean error
gyp ERR! stack Error: EBUSY: resource busy or locked, rmdir 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build'
gyp ERR! stack at Error (native)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "clean"
gyp ERR! cwd C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
gyp ERR! node -v v2.2.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd clean' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Jonathan\AppData\Roaming\npm\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:763:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:210:5)
node-pre-gyp ERR! System Windows_NT 6.3.9600
node-pre-gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
node-pre-gyp ERR! node -v v2.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.29
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd clean' (1)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v2.2.1
npm ERR! npm v2.11.0
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! 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 their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
如果您克隆了 github 存储库,您应该进入克隆的文件夹并 运行 npm install 安装 serialport 的依赖项。
出于某种原因,我正在尝试在我的计算机上手动安装串口模块。我尝试复制 github 文件,然后将其粘贴到 roam 文件夹中,但后来我 运行 进入以下问题。
└─┬ serialport@4.0.1
├── UNMET DEPENDENCY bindings@1.2.1
├── UNMET DEPENDENCY commander@^2.9.0
├── UNMET DEPENDENCY debug@^2.1.1
├── UNMET DEPENDENCY lie@^3.1.0
├── UNMET DEPENDENCY nan@^2.3.5
├── UNMET DEPENDENCY node-pre-gyp@^0.6.26
└── UNMET DEPENDENCY object.assign@^4.0.3
npm ERR! missing: bindings@1.2.1, required by serialport@4.0.1
npm ERR! missing: commander@^2.9.0, required by serialport@4.0.1
npm ERR! missing: debug@^2.1.1, required by serialport@4.0.1
npm ERR! missing: lie@^3.1.0, required by serialport@4.0.1
npm ERR! missing: nan@^2.3.5, required by serialport@4.0.1
npm ERR! missing: node-pre-gyp@^0.6.26, required by serialport@4.0.1
npm ERR! missing: object.assign@^4.0.3, required by serialport@4.0.1
我正在尝试从 windows 命令提示符 运行 serialport-list
。串口的原因。
当我通常以正常方式尝试串行端口时,我 运行 出现以下错误:
vcbuild.exe : error VCBLD0010: Project 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.
vcproj' requires upgrade. Use 'vcbuild /upgrade' or 'devenv /upgrade' to upgrade the project. [C:\Users\Jonathan\AppDat
a\Roaming\npm\node_modules\serialport\build\binding.sln]
我无法应用升级,因为该文件不存在,所以我手动下载了 serialport.vcproj 文件并应用了升级,然后复制了串口节点模块,但仍然无法 运行 serialport-list
关闭命令提示符。
更新
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>vcbuild /upgrade C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.vcproj
Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.30729
Copyright (C) Microsoft Corporation. All rights reserved.
Successfully upgraded project file 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build\serialport.vcproj'.
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>npm install
> serialport@4.0.1 install C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download: https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.1/serialport-v4.0.1-node-v44-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.1 and node@2.2.1 (node-v44 ABI) (falling back to source compile with node-gyp)
C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node clean )
gyp ERR! clean error
gyp ERR! stack Error: EBUSY: resource busy or locked, rmdir 'C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\build'
gyp ERR! stack at Error (native)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "clean"
gyp ERR! cwd C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
gyp ERR! node -v v2.2.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd clean' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Jonathan\AppData\Roaming\npm\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:763:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:210:5)
node-pre-gyp ERR! System Windows_NT 6.3.9600
node-pre-gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Jonathan\AppData\Roaming\npm\node_modules\serialport
node-pre-gyp ERR! node -v v2.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.29
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd clean' (1)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v2.2.1
npm ERR! npm v2.11.0
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! 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 their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
如果您克隆了 github 存储库,您应该进入克隆的文件夹并 运行 npm install 安装 serialport 的依赖项。