Ensure Node.js is installed and that 'node' is the command to run.
()
| 24 | |
| 25 | |
| 26 | def EnsureNodeJsIsInstalled(): |
| 27 | """Ensure Node.js is installed and that 'node' is the command to run.""" |
| 28 | logging.info('entering ...') |
| 29 | |
| 30 | try: |
| 31 | output = subprocess.check_output(['node', '--eval', 'console.log("42")']) |
| 32 | if b'42' == output.strip(): |
| 33 | return |
| 34 | except (subprocess.CalledProcessError, OSError): |
| 35 | pass |
| 36 | Die('Node.js not found. Try "apt-get install nodejs" or follow the install' |
| 37 | 'instructions at' |
| 38 | 'https://github.com/ampproject/amphtml/blob/main/validator/README.md#installation' |
| 39 | ) |
| 40 | |
| 41 | |
| 42 | def CheckPrereqs(): |