Error Installing serverless using NPM on ubuntu 20.04 Desktop

Hello,
I can’t install serverless using NPM, I Need Help !

My NPM Version :

6.14.4

My Installation Command :

$ sudo npm install -g serverless

also

$ sudo npm install -g serverless@1.68.0

This is my log installation :

1015 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/serverless/node_modules/chokidar/node_modules/fsevents):
1016 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
1017 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
1017 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
1017 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
1017 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
1018 verbose stack SyntaxError: Unexpected end of JSON input while parsing near ‘…"},“dist”:{"integrity’
1018 verbose stack at JSON.parse ()
1018 verbose stack at parseJson (/usr/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
1018 verbose stack at consumeBody.call.then.buffer (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
1018 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
1019 verbose cwd /home/
1020 verbose Linux 5.4.0-26-generic
1021 verbose argv “/usr/bin/node” “/usr/bin/npm” “install” “-g” “serverless”
1022 verbose node v10.20.1
1023 verbose npm v6.14.4
1024 error Unexpected end of JSON input while parsing near ‘…"},“dist”:{"integrity’
1025 verbose exit [ 1, true ]

I Need Help to fix it. thks.

1 Like

I got the solution, the problem is not in serverless framework but in npm and can be solved by cleaning the cache with the syntax of $ sudo npm cache clean - force. Thks.

1 Like