2023/4/11日晚遇到的问题
1、问题一
‘CALL “I:\Program Files\nodejs\node.exe” “I:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js”
解决方法:
把环境配置变量里面的 ComSpec删掉就行了
删掉后
环境变量配置我的电脑右击->属性
2、解决完又出现第二个问题
— json-server : 无法加载文件xx\npm\json-server.ps1,因为在此系统上禁止运行脚本
解决方法:
使用管理员方式打开Power Shell
输入Get-ExecutionPolicy,可以查看到当前的策略
输入Set-ExecutionPolicy RemoteSigned,设置当前的策略为RemoteSigned
输入Y
3、报错:json-server Type of “xxx” (string) is not supported.
会报错: json-server Type of “name” (string) is not supported.
原因与json-server的工作方式有关
直接暴露在JSON对象根目录下的每个键都被视为json-server中的单独URL。
需要使用对象或数组对象
{
"username": [
{
"name": "zwy",
"id":1
},
{
"name": "zs",
"id":2
}
]
}
//最外层需要定义一个对象或者数组对象
解决后
PS G:\前端开发\ajax> json-server .\1.json --watch
\{^_^}/ hi!
Loading .\1.json
Done
Resources
http://localhost:3000/username
Home
http://localhost:3000
Type s + enter at any time to create a snapshot of the database
Watching...
Some error occurred Error: listen EADDRINUSE: address already in use ::1:3000
at Server.setupListenHandle [as _listen2] (node:net:1740:16)
at listenInCluster (node:net:1788:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:1937:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::1',
port: 3000
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/144066.html