Comments (7)
When the main.coffee
is loaded, the NODE_PATH
has already been read and stored by the module system, so subsequent modifications to NODE_PATH
won't have any effect on current script.
To modify the module's search paths in main.coffee
, you should append the paths to require('module').globalPaths
:
require('module').globalPaths.push(searchPath);
This feature (modify the search paths after script is loaded) is atom-shell only, I'll document it.
from electron.
Do you think we should use module.globalPaths instead of NODE_PATH for everything? It would be more consistent, but are there are downsides?
from electron.
module.globalPaths
does not work in the renderer, because of a hack that forcing module code to be evaluated under window context.
from electron.
I can't get module.globalPaths to work in the browser process.
I run this code in main.coffee
console.log require('module').globalPaths
require('module').globalPaths.push(resourcePath + "/src/app")
console.log require('module').globalPaths
require('point')
And this is the output
[ '/Users/corey/.node_modules',
'/Users/corey/.node_libraries',
'/Applications/Atom.app/Contents/lib/node',
'/Applications/Atom.app/Contents/Resources/browser/api/lib',
'/Applications/Atom.app/Contents/Resources/common/api/lib' ]
[ '/Users/corey/.node_modules',
'/Users/corey/.node_libraries',
'/Applications/Atom.app/Contents/lib/node',
'/Applications/Atom.app/Contents/Resources/browser/api/lib',
'/Applications/Atom.app/Contents/Resources/common/api/lib',
'/Users/corey/github/atom/src/app' ]
uncaughtException:
Error: Cannot find module 'point'
at Function.Module._resolveFilename (module.js:351:15)
at Function.Module._load (module.js:293:25)
at Module.require (module.js:377:17)
at require (module.js:393:17)
at Object.bootstrapApplication [as preMainMessageLoopRun] (/Applications/Atom.app/Contents/Resources/app/src/main.js:76:12)
from electron.
The ~/github/atom
only contains .coffee
sources, so you have to require coffee-script
:
require('coffee-script')
require('coffee-cache').setCacheDir('/tmp/atom-coffee-cache')
require('module').globalPaths.push(resourcePath + "/src/app")
require('point')
from electron.
Ahh, thanks!
from electron.
This PR landed in electron v1.7.12 🎉
from electron.
Related Issues (20)
- [Feature Request]: Hardware accelerated off-screen rendering HOT 2
- [Bug]: recentDocuments not populating
- [Bug]: Crash when adding child view HOT 4
- Electron SIGSEGV Error When Running in Docker Container HOT 2
- [Bug]: HTML Drag and Drop API not returning event.dataTransfer.files array consistently on all Electron versions
- [Bug]: BrowserView's content is visually wiped when vibrancy is set on Electron version 30 and up
- [Bug]: node_modules/electron/dist/electron exited with signal SIGSEGV HOT 1
- [Bug]: Clicking on the color picker doesn't do anything HOT 4
- [Bug]: New Protocol.handle vs Protocol.registerFileProtocol does not fetch files properly.
- [Bug]: Crash base::subtle::RefCountedBase::ReleaseImpl() EXCEPTION_ACCESS_VIOLATION_READ HOT 1
- [Bug]: Capturing the screen is broken in the newer version (desktopCapturer) HOT 1
- gitHub.com/docker/repo
- [Feature Request]: add config.hideDock to BrowserWindow.setHiddenInMissionControl
- [Bug]: Calling session.defaultSession.webRequest.onHeadersReceived after ready and before window creation causes silent crash
- webContents.getPrintersAsync() not returning printer list on Linux Mint Cinnamon 19.1 HOT 3
- [Bug]: Frameless BrowserView.setAutoResize() is broken in v30.0.1
- [Infra]: Test check CI failed to execute because of npm package not found HOT 3
- [Bug]: <input type="file"> is not showing dialog on click HOT 4
- [Bug]: app.setLoginItemSettings({ openAtLogin: true }) doesnt work in APPX after publishing it.
- [Bug]: <input type=file> not working in WebContentsView HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron.