Closed gkatsev closed 2 years ago
The issue was obliquely build-related, but more specifically an issue with properties of an hls.js instance being referenced in a node runtime, including constants. By moving any of these references to within the corresponding method scopes, this obviates the problem occurring as a result of simply importing or requiring the @mux/videojs-kit in these environments.
Confirmed reproduction of issue in two ways:
@mux/videojs-kit
as a declared dependency
node
to start REPLconst videojs = require('@mux/videojs-kit
); // throws error
% node
Welcome to Node.js v14.17.3.
Type ".help" for more information.
> const videojs = require('@mux/videojs-kit')
Uncaught TypeError: Cannot read property 'NETWORK_ERROR' of undefined
at Object.819 (/Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:77:4852)
at Qe (/Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:78:1629)
at Object.18 (/Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:77:4128)
at Qe (/Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:78:1629)
at /Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:78:2137
at /Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:78:2155
at /Users/cpillsbury/dev/tests/test-vjs-mk-nextjs/test-vjs-mk-nextjs/node_modules/@mux/videojs-kit/dist/index.js:1:83
yarn create next-app
to create an example appyarn
yarn add @mux/videojs-kit
Home
page, add import videojs from '@mux/videojs-kit';
yarn dev
Server Error TypeError: Cannot read property 'NETWORK_ERROR' of undefined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Confirmed solution by:
yarn link
the projectyarn link @mux/videojs-kit
in the aforementioned project(s)
Fixes #59