willviles / ember-useragent

An Ember addon for Fastboot-enabled UserAgent parsing via UAParser.js.
MIT License
37 stars 12 forks source link

Crash on Windows #22

Closed kaba2 closed 6 years ago

kaba2 commented 6 years ago

The update from 6.1 to 7.1 produced the following crash in our program on Windows 10, right at the start of 'yarn':

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Cannot read property '0' of null
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot read property '0' of null
  - name: TypeError
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: TypeError: Cannot read property '0' of null
    at Class.included (C:\Users\kaba\code\wavelength\node_modules\ember-useragent\index.js:8:82)
    at Class.superWrapper [as included] (C:\Users\kaba\code\wavelength\node_modules\core-object\lib\assign-properties.js:34:20)
    at project.addons.forEach.addon (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\broccoli\ember-app.js:596:15)
    at Array.forEach (<anonymous>)
    at EmberApp._notifyAddonIncluded (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\broccoli\ember-app.js:594:25)
    at new EmberApp (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\broccoli\ember-app.js:151:10)
    at module.exports (C:\Users\kaba\code\wavelength\ember-cli-build.js:14:15)
    at Builder.setupBroccoliBuilder (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\models\builder.js:51:19)
    at new Builder (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\models\builder.js:29:10)
    at ServeTask.run (C:\Users\kaba\code\wavelength\node_modules\ember-cli\lib\tasks\serve.js:24:55)

The offending line index.js which produces 'Cannot read property '0' of null' is:

const modulePath = require.resolve('ua-parser-js').match(/node_modules\/.*$/)[0];

Any ideas?

buschtoens commented 6 years ago
const modulePath = require.resolve('ua-parser-js').match(/node_modules\/.*$/)[0];

I would assume that the path separator / (or \/ in the regex) has to be \ (or \\ in the regex) for Windows.

Can you try running this with:

const modulePath = require.resolve('ua-parser-js').match(/node_modules(\/|\\).*$/)[0];
kaba2 commented 6 years ago

That solves the problem, thanks.

buschtoens commented 6 years ago

Would be cool, if you could submit a PR! 😊

kaba2 commented 6 years ago

Done.