I'm new to npm, node and Electron.
My Folder looks like:
-package.json
-index.html
-main.js
-js/myStuff.js
-node_modules
In the file myStuff.js
I have var chokidar = require('chokidar');
but it shows then module not found
error.
In the index.html
I included the myFile.js
like normaly in a script tag.
I did read how node is looking for modules. But that doesn't help cause then it should find it, cause it's looks in all parent dirs for the node_modules folder and then in there for a chokidar folder and in that for the index.js file, which is there.
What am I doing wrong?
It works now, but i have no idea why..
In contrast to other node apps, electron doesn't automatically set your NODE_PATH
to global (ie /usr/bin
) or local (eg node_modules
) folders . So you need to export it manually:
NODE_PATH=/path/to/node_modules electron my_app
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.