http的请求和响应时,要用到node.js和curl这两个工具,可能会遇到这样的问题:
bash: node: command not found
bash: node: curl not found
这两个比较头疼的问题,查资料知道就是环境变量配置的问题,原来win7的系统高级设置需要把path配置两个值,中间要加分号;隔开,这样才避免冲突,哎,比较坑了,这把算是认识path了。
具体的解决方法是:
1)先配置node和curl的安装路径:
计算机,右键,属性,高级系统设置,环境变量,系统变量,新建变量名:NODE_PATH,变量值:D:\Software\nodejs(也就是node安装的路径填上);
新建变量名:CURL_HOME,变量值:D:\Downloads\curl-7.83.1_3-win64-mingw\bin(也就是curl安装的路径填上)
2)同时把node和curl的path配置一下:
找到path变量,在变量值处添加:%CURL_HOME%;%NODE_PATH%,这样重启命令行和vs-code等工具,再验证就ok了。
λ curl -help
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail fast with no output on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
λ node --version
v12.12.0