-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigator is not defined #40
Comments
What version are you using? Are you sure it's cuid causing the error? The node version of cuid shouldn't give you any trouble with browser stuff. |
|
The latest version of cuid is 1.2.5. Try that, first. |
1.2.5 Didn't resolve the problem, either. Maybe something else is conflating what's really going on. I'm trying to run tests via Interestingly I was able to reacreate the problem outside of my app. I created a describe('work', function () {
var cuid = require('cuid')
it('should work', function() {
var canevaluate = typeof navigator == "undefined";
var id = cuid()
console.log('ID', id)
console.log('canEval', canevaluate)
expect(id).to.equal(id)
})
})
work
1) should work
0 passing (9ms)
1 failing
1) work should work:
ReferenceError: navigator is not defined
at Function.browserPrint (specs.js:12825:17)
at cuid (specs.js:12784:27)
at Context.<anonymous> (specs.js:8:18) Does this mean the browserify pre-compile step is evaluated as "hey we're in the browser, navigator is here... no worries" and then chokes when the code is evaluated again inside node? On another note - the latest version is 1.2.5, yet github doesn't have that release tagged? I'm seeing a strange difference in github/cuid/package.json "version": "1.2.5",
"main": "./build/server/cuid.js",
"browserify": "./build/client/cuid.js", node_modules/cuid/package.json "version": "1.2.5",
"main": "./dist/node-cuid.js",
"browserify": "./dist/browser-cuid.js",
|
Interesting. It looks to me like the server version isn't even getting built. @therealklanni |
I strongly suspect this is related to issue 42. Does the current version work for you? |
It doesn't, but the issue may very well still be on my end. I'm thinking the problem is that when running browserify to compact all the |
@ericelliott looking into it. This was working before, might be related to the recent changes, trying to nail it down. In short, the "navigator is not defined" is caused by the fact that node doesn't have a concept of a navigator, so for tests to run they need to be run in a browser, not in node. |
@therealklanni Yeah, but in a Node build, the Here's an ugly workaround in the meantime: specify the exact path/filename to import the correct package instead of |
I think this is related to #42. I believe once we finish resolving that issue it will shed some light on this. |
I just ran into this issue trying to use the new node debugger built into Chrome Dev Tools |
If you want to try to get resolve the build/CI test failures in this PR it should solve this issue. |
I could being doing something really stupid (as is the case normally) but I can't get my tests to pass in Node with cuid.
If I dig a little further, it looks like cuid is expecting the
window.navigator
to exist... but obviously this is not the case when running in a Node process. I am using Testem's launchers to run this particular suite of tests, and perhaps that is where the error lies. Maybe Testem isn't setting an environment variable correctly and therefore some kind ofcuid
check ofif process.env === node
is failing?Any ideas would be appreciated.
The text was updated successfully, but these errors were encountered: