{"_id":"detect-node-es","_rev":"409559","name":"detect-node-es","description":"Detect Node.JS (as opposite to browser environment). ESM modification","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"kashey","email":""}],"time":{"modified":"2021-08-04T05:03:13.000Z","created":"2020-07-27T10:41:11.064Z","1.1.0":"2021-03-18T00:59:32.365Z","1.0.0":"2020-07-27T10:41:11.064Z"},"users":{},"author":{"name":"Ilya Kantor"},"repository":{"type":"git","url":"git+https://github.com/thekashey/detect-node.git"},"versions":{"1.1.0":{"name":"detect-node-es","version":"1.1.0","description":"Detect Node.JS (as opposite to browser environment). ESM modification","main":"es5/node.js","module":"esm/node.js","browser":{"./es5/node.js":"./es5/browser.js","./esm/node.js":"./esm/browser.js"},"types":"es5/node.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/thekashey/detect-node.git"},"keywords":["detect","node"],"author":{"name":"Ilya Kantor"},"license":"MIT","bugs":{"url":"https://github.com/thekashey/detect-node/issues"},"homepage":"https://github.com/thekashey/detect-node","gitHead":"a04ac52015a2052b5006a6f81409fa57987335fb","_id":"detect-node-es@1.1.0","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"shasum":"163acdf643330caa0b4cd7c21e7ee7755d6fa493","size":1854,"noattachment":false,"key":"/detect-node-es/-/detect-node-es-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/detect-node-es/download/detect-node-es-1.1.0.tgz"},"_npmUser":{"name":"kashey","email":"thekashey@gmail.com"},"directories":{},"maintainers":[{"name":"kashey","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detect-node-es_1.1.0_1616029172246_0.45627127939854395"},"_hasShrinkwrap":false,"publish_time":1616029172365,"_cnpm_publish_time":1616029172365},"1.0.0":{"name":"detect-node-es","version":"1.0.0","description":"Detect Node.JS (as opposite to browser environment). ESM modification","main":"es5/node.js","module":"esm/node.js","browser":{"./es5/node.js":"./es5/browser.js","./esm/node.js":"./esm/browser.js"},"types":"es5/node.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/thekashey/detect-node.git"},"keywords":["detect","node"],"author":{"name":"Ilya Kantor"},"license":"ISC","bugs":{"url":"https://github.com/thekashey/detect-node/issues"},"homepage":"https://github.com/thekashey/detect-node","gitHead":"084d6d69cb29e3971ed3fa27dad037d836acfab0","_id":"detect-node-es@1.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"shasum":"c0318b9e539a5256ca780dd9575c9345af05b8ed","size":1854,"noattachment":false,"key":"/detect-node-es/-/detect-node-es-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/detect-node-es/download/detect-node-es-1.0.0.tgz"},"maintainers":[{"name":"kashey","email":""}],"_npmUser":{"name":"kashey","email":"thekashey@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/detect-node-es_1.0.0_1595846470960_0.6989401874513967"},"_hasShrinkwrap":false,"publish_time":1595846471064,"_cnpm_publish_time":1595846471064}},"readme":"## detect-node\n> This is a fork of `detect-node`.\n\nDifferences:\n- uses named export {isNode}\n- has d.ts integrated\n- supports ESM\n\n### Install\n\n```shell\nnpm install --save detect-node-es\n```\n\n### Usage:\n\n```diff\n-var isNode = require('detect-node');\n+var {isNode} = require('detect-node-es');\n\nif (isNode) {\n  console.log(\"Running under Node.JS\");\n} else {\n  alert(\"Hello from browser (or whatever not-a-node env)\");\n}\n```\n\nThe check is performed as:\n```js\nmodule.exports = false;\n\n// Only Node.JS has a process variable that is of [[Class]] process\ntry {\n module.exports = Object.prototype.toString.call(global.process) === '[object process]' \n} catch(e) {}\n\n```\n\nThanks to Ingvar Stepanyan for the initial idea. This check is both **the most reliable I could find** and it does not use `process` env directly, which would cause browserify to include it into the build.\n","_attachments":{},"homepage":"https://github.com/thekashey/detect-node","bugs":{"url":"https://github.com/thekashey/detect-node/issues"},"license":"MIT"}