微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

安装 express-mysql-session

如何解决安装 express-mysql-session

我正在开发一个 nodejs 项目,该项目使用passportjs 对用户进行身份验证。我正在使用 MysqL 作为数据库。 现在我想使用“express-MysqL-session”包来实现会话存储。

当我使用 npm 安装 express-MysqL-session 时,它显示错误

$ npm install express-MysqL-session --save
 npm ERR! Unexpected end of JSON input while parsing near '...ies":{"express":"3.3.'

 npm ERR! A complete log of this run can be found in:
 npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2021-07-22T10_22_41_836Z-debug.log

但是当我安装任何其他软件包时,它已成功安装

这是运行的“完整日志”

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node.exe',1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',1 verbose cli   'install',1 verbose cli   'express-MysqL-session',1 verbose cli   '--save'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.18.0
4 verbose npm-session 63020bd35662f4f0
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/express-MysqL-session 20ms (from cache)
8 silly fetchPackageMetaData error for express-MysqL-session@latest Unexpected end of JSON input while parsing near '...ies":{"express":"3.3.'
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 367ms
11 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ies":{"express":"3.3.'
11 verbose stack     at JSON.parse (<anonymous>)
11 verbose stack     at parseJson (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
11 verbose stack     at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
11 verbose stack     at processticksAndRejections (internal/process/task_queues.js:97:5)
12 verbose cwd D:\Projects\AppName
13 verbose Windows_NT 6.1.7601
14 verbose argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express-MysqL-session" "--save"
15 verbose node v12.18.0
16 verbose npm  v6.14.4
17 error Unexpected end of JSON input while parsing near '...ies":{"express":"3.3.'
18 verbose exit [ 1,true ]

这是 "package.json" 文件

{
    "name": "App Name","version": "1.0.0","description": "","main": "index.js","scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
 },"keywords": [],"author": "","license": "ISC","dependencies": {
     "bcrypt": "^5.0.1","body-parser": "^1.19.0","dotenv": "^8.2.0","ejs": "^3.1.5","express": "^4.17.1","express-flash": "0.0.2","express-session": "^1.17.2","my-sql": "^1.2.15","MysqL": "^2.18.1","passport": "^0.4.1","passport-local": "^1.0.0",}
}

在其他项目中安装时不起作用。

现在我该怎么办???

感谢所有尝试回答的人。

解决方法

可能缓存损坏?

npm cache clean --force

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。