Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including nice-try with all npm packages installed. Try it out:

var niceTry = require("nice-try")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

nice-try v2.0.0

Tries to execute a function and discards any error that occurs


Travis Build Status AppVeyor Status Coverage Status Dependencies Greenkeeper badge

A function that tries to execute a function and discards any error that occurs.


npm install nice-try


const niceTry = require('nice-try')

niceTry(() => JSON.parse('true')) // true
niceTry(() => JSON.parse('truee')) // undefined
niceTry() // undefined
niceTry(true) // undefined



  • fn {Function} Function that might or might not throw an error.


  • {?*} Return-value of the function when no error occurred.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free