vs code里编译出错Load serialport failed.

Wipoper
发布于 2020-11-18 21:24
浏览
1收藏

burn后出现

> Executing task: hpm run 'upload' <
Start flash images...
Load serialport failed.
Please make sure system variable 'NODE_PATH' has been configured.
You can run "npm config get prefix" to get prefix path, Set NODE_PATH to prefix\node_modules
Do you want to install modules: serialport now? y/n (default:y):

我已经设置过系统变量了且确认无误//环境系统变量配置:NODE_PATH  C:\Users\Administrator\AppData\Roaming\npm\node_modules

输入y回车后。弹出:

> Executing task: npm install -g serialport <
(node:4460) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
> @serialport/bindings@9.0.2 install C:\Users\Administrator\AppData\Roaming\npm\node_modules\serialport\node_modules\@serialport\bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
(node:10052) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
prebuild-install WARN install Request timed out
C:\Users\Administrator\AppData\Roaming\npm\node_modules\serialport\node_modules\@serialport\bindings>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node 
"C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
  serialport.cpp
  serialport_win.cpp
  win_delay_load_hook.cc
C:\\Users\\Administrator\\AppData\\Local\\node-gyp\\Cache\\14.15.0\\x64\\node.lib : fatal error LNK1106: 文件无效或磁盘已满: 无法查找到 0x376F20 [C:\Users\Admi
nistrator\AppData\Roaming\npm\node_modules\serialport\node_modules\@serialport\bindings\build\bindings.vcxproj]
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Administrator\AppData\Roaming\npm\node_modules\serialport\node_modules\@serialport\bindings
gyp ERR! node -v v14.15.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @serialport/bindings@9.0.2 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @serialport/bindings@9.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-11-18T13_16_30_762Z-debug.log
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm install -g serialport" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
> Executing task: hpm run 'upload' <
Start flash images...
Load serialport failed.
Please make sure system variable 'NODE_PATH' has been configured.
You can run "npm config get prefix" to get prefix path, Set NODE_PATH to prefix\node_modules
Do you want to install modules: serialport now? y/n (default:y):

试了n多次,一直解决不了,请问您应该怎么办?

 

分类
已于2020-11-18 21:24:01修改
收藏 1
回复
举报
14条回复
按时间正序
/
按时间倒序
Wipoper
Wipoper

之前串口读写功能已经安装了。

C:\Users\Administrator>npm install -g @serialport/parser-readline
+ @serialport/parser-readline@9.0.1
updated 1 package in 1.21s
回复
2020-11-18 21:27:25
Wipoper
Wipoper

检查prefix路径也是有的

C:\Users\Administrator>npm config get prefix
C:\Users\Administrator\AppData\Roaming\npm

回复
2020-11-18 21:32:25
Wipoper
Wipoper 回复了 Wipoper
检查prefix路径也是有的 C:\Users\Administrator>npm config get prefix C:\Users\Administrator\AppData\Roaming\npm

hpm版本

C:\Users\Administrator>hpm -V
1.0.1
回复
2020-11-18 21:33:38
红叶亦知秋
红叶亦知秋

问题如果贴到问答区,可以吸引更多的愿意回答问题的回复。

回复
2020-11-19 09:56:02
馥有诗书气自甄
馥有诗书气自甄 回复了 Wipoper
hpm版本 C:\Users\Administrator>hpm -V 1.0.1

1、你的NODE_PATH以及其他的配置是没有问题的,这个可以从你上面反馈的截图可以看出;

2、hpm run 'upload'的时候,下载和serialport相关的包有两个:serialport和@serialport/parser-readline,所以你目前的环境中缺少了serialport导致在vscode中一直报错需要重复下载;

3、 目前来看,你下载serialport失败的原因主要是因为npm在下载serialport等包时会有一个预编译的过程,然后因为你电脑中缺少预编译的环境所以下载失败

---------------------------------------------分割线------------------------------------------------------------

Q4:通过cmd等命令行工具下载serialport等失败,怎么解决?

解决措施:

当前下载依赖缺失,因为当下载serialport等包时需要预编译环境:开发者可以在安装Nodejs过程中勾选安装依赖软件,然后在Nodejs安装成功后会自动安装所依赖的软件与环境。
如果开发者无法通过自动安装:开发者可以手动安装Microsoft Visual Studio并选择合适的C/C++编译器进行安装,例如Microsoft Visual C++ 2017。

回复
2020-11-19 10:55:30
Wipoper
Wipoper 回复了 馥有诗书气自甄
1、你的NODE_PATH以及其他的配置是没有问题的,这个可以从你上面反馈的截图可以看出; 2、hpm run &#039;upload&#039;的时候,下载和serialport相关的包有两个:serialport和@serialport/parser-readline,所以你目前的环境中缺少了serialport导致在vscode中一直报错需要重复下载; 3、 目前来看,你下载serialport失败的原因主要是因为npm在下载serialport等包时会有一个预编译的过程,然后因为你电脑中缺少预编译的环境所以下载失...

    我之前的nodejs安装完,再Windows PowerShell自动安装总是不成功,卡住就不动了。应该是这一步出现问题,才导致后面没有预编译环境。

    我现在安装了Microsoft Visual C++ 2017,也安装了桌面C++编译器。我不知道在C++编译器内怎么安装现在开发板对应的环境。

回复
2020-11-19 20:30:57
Wipoper
Wipoper

nodejs安装完成后自动安装其他相应程序不成功,

使用“1”个参数调用“DownloadString”时发生异常:“操作超时”
所在位置 行:1 字符: 82
+ ... pe]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('ht ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

Chocolatey v0.10.15
Upgrading the following packages:
python;visualstudio2017-workload-vctools
By upgrading you accept licenses for the packages.
python is not installed. Installing...
Error retrieving packages from source 'https://chocolatey.org/api/v2/':
 Could not connect to the feed specified at 'https://chocolatey.org/api/v2/'. Please verify that the package source (loc
ated in the Package Manager Settings) is valid and ensure your network connectivity.
python not installed. The package was not found with the source(s) listed.
 Source(s): 'https://chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.
visualstudio2017-workload-vctools is not installed. Installing...
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading vcredist140 14.28.29325.2... 100%
Progress: Downloading vcredist140 14.28.29325.2... 100%
Progress: Downloading vcredist140 14.28.29325.2... 100%
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
visualstudio2017-workload-vctools not installed. An error occurred during installation:
 操作超时
visualstudio2017-workload-vctools package files upgrade completed. Performing other installation steps.
The upgrade of visualstudio2017-workload-vctools was NOT successful.
visualstudio2017-workload-vctools not installed. An error occurred during installation:
 操作超时

Chocolatey upgraded 0/2 packages. 2 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - python - python not installed. The package was not found with the source(s) listed.
 Source(s): 'https://chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.
 - visualstudio2017-workload-vctools (exited 1) - visualstudio2017-workload-vctools not installed. An error occurred dur
ing installation:
 操作超时
Type ENTER to exit:
回复
2020-11-19 20:44:03
馥有诗书气自甄
馥有诗书气自甄 回复了 Wipoper
nodejs安装完成后自动安装其他相应程序不成功, 使用“1”个参数调用“DownloadString”时发生异常:“操作超时” 所在位置 行:1 字符: 82 + ... pe]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString(&#039;ht ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodIn...

根据报错信息,好像是安装python失败了,你电脑中有python环境?

回复
2020-11-20 16:28:48
馥有诗书气自甄
馥有诗书气自甄 回复了 馥有诗书气自甄
根据报错信息,好像是安装python失败了,你电脑中有python环境?

我在另一个帖子里看到了,你有安装python。这个我需要在定位一下具体是什么原因,你可以先参考一下这个文档里的方法,我解决后在重新告诉你

 

https://developer.huawei.com/consumer/cn/forum/topicview?tid=0202352443767730634&fid=0101303901040230869

回复
2020-11-20 16:32:28
Wipoper
Wipoper 回复了 馥有诗书气自甄
我在另一个帖子里看到了,你有安装python。这个我需要在定位一下具体是什么原因,你可以先参考一下这个文档里的方法,我解决后在重新告诉你 https://developer.huawei.com/consumer/cn/forum/topicview?tid=0202352443767730634&fid=0101303901040230869

用以上论坛内文件粘贴相应位置,没有之前的npm ERR了,应该是解决了部分问题。尝试在vscode里编译,反复提示加载模块Do you want to install modules: serialport now? y/n (default:y):。但其实每次y后,都没用。觉得就是之前的下载的node-v14.15.0-x64.msi 每次安装到后期的自动配置环境都卡主不动,到时后期这么多问题。你们的node-v14.15.0-x64都能自动配置环境是么。还是我安装的win10系统哪里不对。郁闷~

> Executing task: hpm run 'upload' <
Start flash images...
Load serialport failed.
Please make sure system variable 'NODE_PATH' has been configured.
You can run "npm config get prefix" to get prefix path, Set NODE_PATH to prefix\node_modules
Do you want to install modules: serialport now? y/n (default:y):
y
> Executing task: npm install -g serialport <
=====================================================下一页
> Executing task: npm install -g serialport <
(node:3228) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
> serialport@9.0.2 postinstall C:\Users\Administrator\AppData\Roaming\npm\node_modules\serialport
> node thank-you.js
Thank you for using serialport!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/serialport/donate
+ serialport@9.0.2
updated 1 package in 9.064s
Terminal will be reused by tasks, press any key to close it.
> Executing task: hpm run 'upload' <
Start flash images...
Load serialport failed.
Please make sure system variable 'NODE_PATH' has been configured.
You can run "npm config get prefix" to get prefix path, Set NODE_PATH to prefix\node_modules
Do you want to install modules: serialport now? y/n (default:y):
已于2020-11-23 20:09:31修改
回复
2020-11-23 20:06:10
Wipoper
Wipoper

node js 下的install_tool.bat

回复
2020-11-23 20:31:33
馥有诗书气自甄
馥有诗书气自甄 回复了 Wipoper
node js 下的install_tool.bat

那个论坛里的包匹配的Node.js的版本是v12.x.x的,要不你试一下换一下nodejs的版本。

然后,

1、下载的serialport包放到{prefix}\node_modules\目录下;

2、在环境变量中配置NODE_PATH={prefix}\node_modules;

3、在环境变量中配置{prefix}的路径;

然后打开vscode应该可以直接使用的

获取{prefix}的方法:npm config get prefix

回复
2020-11-24 14:20:43
mb5fb91f479bb39
mb5fb91f479bb39

这个问题还有别的办法吗,上面的都试了还是不成功

回复
2020-12-6 15:02:45
码工许师傅
码工许师傅

失败的原因是—— serialport 包中包含一些C/C++代码,并且需要在安装时进行编译;

这里失败很可能是安装nodejs 的时候没有勾选 “Tools for Native Modules”  选项(如果安装过程中勾选了这个选项,安装 nodejs过程中会安装VSBuild Tools和 Python);

 

后续的解决方法有两种:

1. 安装 windows-build-tools 包:npm install -g windows-build-tools

2. 卸载nodejs重新安装,安装过程中勾选“Tools for Native Modules”;

 

安装windows-build-tools过程中可能会遇到PowerShell无法执行的问题,解决方法有两种:

1. 修改PowerShell的执行策略(参考微软文档),重新执行 npm install -g windows-build-tools 命令;

2. 直接打开 C:\Users\Administrator\.windows-build-tools 目录,安装下面的 python-2.x.yy.amd64.msi 和  vs_BuildTools.exe

已于2020-12-9 14:56:01修改
回复
2020-12-8 19:25:30
回复
    相关推荐