首页 > 解决方案 > 在 Linuxmint 20.1 上安装无服务器时出错

问题描述

我想将无服务器安装为全局。 npm install -g serverless

但是在安装过程中,我遇到了同样的错误

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/serverless/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! Unexpected end of JSON input while parsing near '...","querystring":"^0.2'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fathisiddiqi/.npm/_logs/2020-09-17T07_24_40_981Z-debug.log

我有干净的 npm 缓存,npm cache clean --force 我又试了一次,又遇到了这样的错误

npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/lodash (over 30000ms)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fathisiddiqi/.npm/_logs/2020-09-17T07_26_46_746Z-debug.log

最后,我尝试再次安装无服务器。但仍然收到消息

npm ERR! Unexpected end of JSON input while parsing near '...TTOgEjCFo9YXvGwfWu94f'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fathisiddiqi/.npm/_logs/2020-09-17T07_30_56_320Z-debug.log

请帮我。谢谢!

标签: amazon-web-servicesnpmserverless

解决方案


第一的

npm cache clean --force

第二

要将所有包更新到新的主要版本,请全局安装 npm-check-updates 包:

npm install -g npm-check-updates

然后运行它:

ncu -u

这会将 package.json 文件中的所有版本提示升级为依赖项和 devDependencies,因此 npm 可以安装新的主要版本。

您现在已准备好运行更新:

npm update

然后install your package


推荐阅读