mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix Cannot read property 'parent' of undefined in node
This happens in webpack bundle in node server rendering react application: ```js TypeError: Cannot read property 'parent' of undefined at Object.eval (webpack:///./node_modules/paper/dist/node/self.js?:20:28) at eval (webpack:///./node_modules/paper/dist/node/self.js?:62:30) at Object../node_modules/paper/dist/node/self.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:34531:1) at __webpack_require__ (/home/bojan/www/climbuddy/client/server/map.bundle.js:26:30) at Object.eval (webpack:///./node_modules/paper/dist/paper-core.js?:35:16) at eval (webpack:///./node_modules/paper/dist/paper-core.js?:14798:3) at Object../node_modules/paper/dist/paper-core.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:34553:1) at __webpack_require__ (/home/bojan/www/climbuddy/client/server/map.bundle.js:26:30) at eval (webpack:///./node_modules/react-paper-bindings/lib/View.js?:15:18) at Object../node_modules/react-paper-bindings/lib/View.js (/home/bojan/www/climbuddy/client/server/map.bundle.js:37188:1) ```
This commit is contained in:
parent
e7f09af890
commit
6925888024
1 changed files with 1 additions and 1 deletions
|
@ -17,7 +17,7 @@ var path = require('path');
|
||||||
// Determine the name by which name the module was required (either 'paper',
|
// Determine the name by which name the module was required (either 'paper',
|
||||||
// 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
|
// 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
|
||||||
// exceptions should be thrown or if loading should fail silently.
|
// exceptions should be thrown or if loading should fail silently.
|
||||||
var parent = module.parent.parent,
|
var parent = module.parent ? module.parent.parent : null,
|
||||||
requireName = parent && path.basename(path.dirname(parent.filename));
|
requireName = parent && path.basename(path.dirname(parent.filename));
|
||||||
requireName = /^paper/.test(requireName) ? requireName : 'paper';
|
requireName = /^paper/.test(requireName) ? requireName : 'paper';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue