开发者

node.js express require?

开发者 https://www.devze.com 2023-02-13 22:09 出处:网络
In an example I see something like this: var uid = require(\"../support/express/support/connect/lib/connect/utils\").uid

In an example I see something like this:

var uid = require("../support/express/support/connect/lib/connect/utils").uid

var express = require("express")开发者_运维技巧 is OK!

var uid = require("express").uid is undefined

I installed express with npm.

How should I require the uid?


express utilizes connect under its hoods which gets installed along with express.

In this case, you want to access the uid function of connect:

> require('connect').utils.uid(40)
'3DQD2XfAd19uL1r7LK6ZkIrFooSOGGVkGePI36HL'

Since:

> require('connect')
{ version: '0.5.5',
  utils: 
   { md5: [Function],
     defaultMime: 'application/octet-stream',
     toBoolean: [Function],
     merge: [Function],
     uid: [Function],
     ...

> require('connect').utils
{ md5: [Function],
  defaultMime: 'application/octet-stream',
  toBoolean: [Function],
  merge: [Function],
  uid: [Function],
  ...

etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消