lloeki / matterfront

Mattermost frontend app for OS X, Windows and Linux
MIT License
152 stars 27 forks source link

'mkdirp' not found #50

Closed LongLiveCHIEF closed 8 years ago

LongLiveCHIEF commented 8 years ago

With the latest version (1.1.0), using npm start runs the app without issues, however, running the app from a distribution (after running npm run build) causes an error: screen shot 2015-12-05 at 11 25 04 am

I suspect this is due in part to incorrect usage of node modules in the renderer process. For reference:

teetrinkers commented 8 years ago

The build works for me if I add nconf, mkdirp and path-extra to src/package.json. Which makes sense, I guess, because that is the package.json used be the electron-packager. settings.js and its dependencies to nconf are only used from main.js, which is the main process, so I don't think it has anything to do with an incorrect usage in the renderer process. Though I wonder why it works with npm start without any changes to the package.json.

LongLiveCHIEF commented 8 years ago

@teetrinkers here's what I think is going on, and why it has the behavior you mention.

When you use npm start, it's not using the asar to resolve files/dependencies. That means it will resolve require calls normally, starting with node_modules. However, when you package everything into an asar, there is no access to the global scope from require, and modules must be resolved from file paths instead.

I actually think the second package.json slipped back in during a rebase and shouldn't be there. However, when you run npm install on that package.json, it puts the modules that are trying to be used by the browser/renderer process into the file path.

However, I don't think this is supposed to be allowed, because it's leaking native node stuff into the browser process, and opens up security issues.

According to the docs, this sort of requirement is supposed to be met by utilizing either the ipc module or remote module.

LongLiveCHIEF commented 8 years ago

closed with patch v1.1.1