Skip to content

Commit

Permalink
Revert "Remove handling of below node 8"
Browse files Browse the repository at this point in the history
This reverts commit f41de4c.
  • Loading branch information
timneutkens committed May 2, 2019
1 parent f41de4c commit af254a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions errors/old-node-version.md
@@ -0,0 +1,10 @@
# Old Node Version

#### Why This Error Occurred

In order to execute code that contains the `async` or `await` keywords, you need to have at least version 8.0.0 of [Node.js](https://nodejs.org/en/) installed on the device that runs `micro`. If that's not the case, you will see this error.

#### Possible Ways to Fix It

- Ensure that at least version 8.0.0 of [Node.js](https://nodejs.org/en/) is installed
- [Transpile](https://github.com/zeit/micro#transpilation) the code of your microservice
12 changes: 12 additions & 0 deletions lib/handler.js
Expand Up @@ -12,6 +12,18 @@ module.exports = async file => {
}
} catch (err) {
logError(`Error when importing ${file}: ${err.stack}`, 'invalid-entry');

if (
err instanceof SyntaxError &&
/\s+async\s+/.test(err.stack) &&
Number(process.versions.node.split('.')[0]) < 8
) {
logError(
'In order for `async` & `await` to work, you need to use at least Node.js 8!',
'old-node-version'
);
}

process.exit(1);
}

Expand Down

0 comments on commit af254a0

Please sign in to comment.