Closed BusfyJan closed 7 years ago
I found the problem. It is because this line in index.js: https://github.com/entwicklerstube/babel-plugin-root-import/blob/master/index.js#L1 When I run app in dev mode I run it from project root, so process.cwd() is project root. But when I am running packaged app double-clicking the app icon from desktop, process.cwd() is '/' at that moment.
Is it possible to change this lib's behavior to optionally pass root path? Because it is not always project root (f.e. when running using double-click on released app icon)
Another way would be to use global.rootPath = path.dirname(path.dirname(__dirname)) because index.js is located in project/node_modules/babel-plugin-root-import - 2 directories up should be project root.
I've resolved this issue by changing my node process CWD to project root Something like: process.chdir(__dirname);
Everything is working just fine on dev, but when I package app using electon-packager, imports are no longer working when I run packaged app.
Uncaught Error: Cannot find module '../../../../../../../../../../../../src/component/App'
It looks like it is trying to go up the directory tree from release version of app to the project root.
Dev folder structure is: projectRoot/src/component/App.jsx Released package is inside project: projectRoot/release/appName/appName/Contents/Resources/app/src/component/App.jsx