paralleldrive / cuid

Collision-resistant ids optimized for horizontal scaling and performance.
Other
3.44k stars 123 forks source link

TypeError: process.pid is undefined #77

Closed serhiipalash closed 6 years ago

serhiipalash commented 7 years ago

Didn't update any package or system environment, but today when I call cuid() I get

TypeError: process.pid is undefined nodePrint [path to my react component] cuid webpack:///./~/cuid/dist/node-cuid.js?:49:23

Using cuid: 1.3.8 webpack: 2.2.0 webpack-dev-server: 2.2.0 node v6.9.4 npm v3.10.10 yarn 0.20.3

Tried on cuid@1.2.0, got the same result.

ericelliott commented 7 years ago

You can see that webpack is trying to use node-cuid.js instead of the browser build. I assume you're seeing this error in the browser?

serhiipalash commented 7 years ago

Yes, I am seeing this error in the browser.

ericelliott commented 7 years ago

Tell Webpack to use the browser build (see the "browser" key in package.json). I'm not sure why it's not respecting the "browser" key -- do you have a highly customized browser build?

serhiipalash commented 7 years ago

Hm, it worked when I added this to my package.json

"browser": {
    "cuid": "./node_modules/cuid/dist/browser-cuid.js"
}

Not sure why it was broken. I have target: 'web' in my webpack.config.js

ericelliott commented 7 years ago

Can you create a PR?