serverless: Error: Cannot find module spawn-sync/postinstall
This is a Bug Report
Description
For bug reports:
- What went wrong?
when running “npm install -g serverless”, it fail.
root@backup:~# npm install -g serverless
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= integrity checksum failed when using sha1: wanted sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= but got sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==. (15621 bytes)
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
/root/.nvm/versions/node/v8.1.4/bin/serverless -> /root/.nvm/versions/node/v8.1.4/lib/node_modules/serverless/bin/serverless
/root/.nvm/versions/node/v8.1.4/bin/slss -> /root/.nvm/versions/node/v8.1.4/lib/node_modules/serverless/bin/serverless
/root/.nvm/versions/node/v8.1.4/bin/sls -> /root/.nvm/versions/node/v8.1.4/lib/node_modules/serverless/bin/serverless
> spawn-sync@1.0.15 postinstall /root/.nvm/versions/node/v8.1.4/lib/node_modules/serverless/node_modules/spawn-sync
> node postinstall
module.js:328
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v8.1.4/lib/node_modules/serverless/node_modules/spawn-sync/postinstall'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! spawn-sync@1.0.15 postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spawn-sync@1.0.15 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-09-28T09_13_12_283Z-debug.log
root@backup:~#
- What did you expect should have happened?
Install serverless with out error.
- What was the config you used?
root@backup:~# node --version
v8.1.4
root@backup:~# which node
/root/.nvm/versions/node/v8.1.4/bin/node
root@backup:~#
- What stacktrace or error message from your provider did you see?
Additional Data
- Serverless Framework Version you’re using:
Install failed.
- Operating System:
Ubuntu 16.04
- Stack Trace:
Posted full error above, if any other info required, let me know.
- Provider Error messages:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 18 (4 by maintainers)
Finally found the solution, https://github.com/ForbesLindesay/spawn-sync/issues/42#issuecomment-236502384. Exact commands I executed:
npm install -g try-thread-sleep npm install -g serverless --ignore-scripts spawn-sync
and now serverless is working. It installed 1.25.0 successfully.
Experiencing this issue here as well. Using macOS.
npm install -g serverless --ignore-scripts spawn-syncgot me past this on RHEL7 / node 8.12.0.Noting that this resulted in serverless pulling in spawn-sync@2.0.0, whereas without the
--ignore-scriptsoption it seemed to be trying and failing to install spawn-sync@1.0.15.https://github.com/ForbesLindesay/spawn-sync README now states that spawn-sync is just a stub and should no longer be included in projects as a dependency. Maybe serverless just needs to drop it out?
Try npm install package_name --unsafe-perm
it works for me…
I had the same issue and realised that I had not have serverless within my package.json so on CI/CD deployment it couldn’t find serverless whereas when I run locally I have it installed globally.