package.json
"name": "billingapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"rebuild": "electron-rebuild -f -w billingapp"
},
"author": "S Kundu",
"license": "ISC",
"dependencies": {
"electron": "^1.7.11",
"sqlite3": "^3.1.13"
}
"devDependencies": {
"electron-rebuild": "^1.7.3"
}
index.js
const electron = require('electron');
const path = require('path');
const url = require('url');
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(path.join(__dirname, 'sample.db'));
const {app, BrowserWindow, Menu, ipcMain} = electron;
let mainWindow;
app.on('ready', function(){
// Create the login window
mainWindow = new BrowserWindow({
resizable: true,
fullscreen: false
});
// Load html in window
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'login.html'),
protocol: 'file:',
slashes: true
}));
});
login.html
<h1>Welcome to billing system</h1>
These are the code files.
Steps to install NPM Packages
npm install electron
npm install sqlite3
Its working perfect when I remove bellow code:
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(path.join(__dirname, 'sample.db'));
But with this code , while running
npm start
is getting bellow error:
App threw an error during load
Error: Cannot find module
'C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node'
at Module._resolveFilename (module.js:470:15)
at Function.Module._resolveFilename (C:\Users\sintu\Desktop\BillingSystem\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Object. (C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\sqlite3.js:190:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
when I run npm run rebuild , I get bellow error
× Rebuild Failed
An unhandled error occurred inside electron-rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=1.7.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-win32-x64.tar.gz"
gyp ERR! cwd C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Failed with exit code: 1
Error: Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=1.7.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-win32-x64.tar.gz"
gyp ERR! cwd C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Failed with exit code: 1
at SafeSubscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\spawn-rx\lib\src\index.js:277:84)
at SafeSubscriber.__tryOrUnsub (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:239:16)
at SafeSubscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:198:26)
at Subscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:129:26)
at Subscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:103:18)
at MapSubscriber.Subscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:129:26)
at MapSubscriber.Subscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:103:18)
at SafeSubscriber._next (C:\Users\sintu\Desktop\billingApp\node_modules\spawn-rx\lib\src\index.js:251:65)
at SafeSubscriber.__tryOrUnsub (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:239:16)
at SafeSubscriber.next (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:186:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! billingapp#1.0.0 rebuild: electron-rebuild -f -w billingapp
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the billingapp#1.0.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sintu\AppData\Roaming\npm-cache_logs\2018-01-30T15_36_46_678Z-debug.log
it seems you have many problems with your scripts, but you also encountered a rare issue with sqlite.
0) You can find my Github source here that is working until this error :
Cannot read property 'on' of undefined
but that is another problem :D
1) Your package.json is not well formated (there is no start script for example)
New package.json
{ // there was no begining bracket
"name": "billingapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"rebuild": "electron-rebuild -f -w billingapp",
"start": "node index.js" // new start script
},
"author": "S Kundu",
"license": "ISC",
"dependencies": {
"electron": "^1.7.11",
"sqlite3": "^3.1.0" // I used this version
},
"devDependencies": {
"electron-rebuild": "^1.7.3"
}
}
2) When I installed sqlite I encountered this issue https://github.com/mapbox/node-sqlite3/issues/758
It seems sqlite3 is not working with the last version of nodejs, so you need to install node#8.9.3 you can use nvm for that:
see comment on sqlite3 issue
treedbox commented on 20 Dec 2017
Related
This is my package.json file:
{
"name": "pro-mern-stack",
"version": "1.0.0",
"description": "first init",
"main": "index.js",
"scripts": {
"start": "nodemon server.js server.js",
"compile": "babel src --presets react,es2015 --out-dir static",
"watch": "babel src --presets react,es2015 --out-dir static --watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Yusuf",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"mongodb": "latest"
},
"devDependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.2"
}
}
I'M TRYING TO RUN npm start TO START THE WATCHER BUT I KEEP GETTING THIS ERROR:
> nodemon server.js server.js
C:\MERN\pro-mern-stack\node_modules\nodemon\lib\monitor\run.js:356
let sig = signal.replace('SIG', '');
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\MERN\pro-mern-stack\node_modules\nodemon\lib\monitor\index.js:2:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! pro-mern-stack#1.0.0 start: `nodemon server.js server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pro-mern-stack#1.0.0 start script 'nodemon server.js server.js'.
npm ERR! This is most likely a problem with the pro-mern-stack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon server.js server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs pro-mern-stack
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls pro-mern-stack
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\mern\pro-mern-stack\npm-debug.log
I'm running with powershell on windows 10. I've tried installing globally, didn't work. Also have the latest version of nodemon. Please, how can i fix this? I've reinstalled nodemon several times, keep getting the same error, even when I run it directly in the console. Thanks!
I see issue in the npm script. You should just update it to nodemon server.js
I get this error while doing an npm start:
PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader> npm start
> react-box#0.1.0 start C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader
> node scripts/start.js
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'dotenv'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader\scripts\
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-box#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-box#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output ab
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Concierge\AppData\Roaming\npm-cache\_logs\2018-11-17T04_27_59_461Z-debug
PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader>
and when I run command npm install, I get this error:
> scrypt#6.0.3 preinstall /Users/user/Documents/pdfuploader/node_modules/scrypt
> node node-scrypt-preinstall.js
> scrypt#6.0.3 install /Users/user/Documents/pdfuploader/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/Documents/pdfuploader/node_modules/scrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt#6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt#6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2018-11-18T05_45_00_864Z-debug.log`
I tried to set up the pythonpath like here: https://www.tutorialspoint.com/How-to-set-your-python-path-on-Mac but it didn't help
I just sort it out by using this tutorial to insert that path /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages :
https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
but then again i got that error when npm run start: `users-Air:pdfuploader user$ npm run start
client#0.1.0 start /Users/user/Documents/pdfuploader
react-scripts start
Could not find a required file.
Name: index.html
Searched in: /Users/user/Documents/pdfuploader/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2018-11-18T06_44_50_004Z-debug.log`
Files which i am trying to npm run start:
https://github.com/damianjnc/pdfuploader
Some of the nodeJS modules are written in c++, and need to be compiled when being installed. This process requires python2 to be installed. Now, most Macs actually have python2 installed by default, but 'python' might not be on your executables path yet.
On a Mac, the python application is typically located at /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7. If there is no 'Python.framework' folder in /System/Library/Frameworks/ you will need to install python. If it is there, then simply symlink the previously mentioned python2.7 executable in /usr/bin. Also ensure that /usr/bin is present on your executable path by typing echo $PATH on your terminal.
To create a symlink run:
cd /usr/bin
sudo ln -s /path/to/original/python python
i did a fresh "npm init".
put entry point : "index.html"
then installed lite-server : npm install lite-server --save-dev
also updated the package.json
{
"name": "newjs",
"version": "1.0.0",
"description": "nothing",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start" : "npm run lite",
"lite" : "lite-server"
},
"author": "",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.3.0"
}
}
But when I did "npm start" , getting this error
D:\mudit\newjs>npm start
newjs#1.0.0 start D:\mudit\newjs
npm run lite
> newjs#1.0.0 lite D:\mudit\newjs
> lite-server
Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server: { baseDir: './', middleware: [ [Function], [Function] ] } }
D:\mudit\newjs\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\engine.io\node_modules\ws\index.js:9
const WebSocket = require('./lib/WebSocket');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Server.init (D:\mudit\newjs\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\engine.io\lib\server.js:115:16)
at new Server (D:\mudit\newjs\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\engine.io\lib\server.js:65:8)
at Function.attach (D:\mudit\newjs\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\engine.io\lib\engine.io.js:123:16)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lite"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! newjs#1.0.0 lite: `lite-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the newjs#1.0.0 lite script 'lite-server'.
npm ERR! This is most likely a problem with the newjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! lite-server
npm ERR! You can get their info via:
npm ERR! npm owner ls newjs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\mudit\newjs\npm-debug.log
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! newjs#1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the newjs#1.0.0 start script 'npm run lite'.
npm ERR! This is most likely a problem with the newjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run lite
npm ERR! You can get their info via:
npm ERR! npm owner ls newjs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\mudit\newjs\npm-debug.log
Please Help as I am not even able to get the lite-server running.
thanks in advance.
I have started with electron today and followed a guide to create a simple application browser window and I ran npm start in the command window and it displayed a lot of errors after I had entered it, I have posted the information below and my code.
Console error:
C:\Users\Administrator\Desktop\electron>npm start
> breef#1.0.0 start C:\Users\Administrator\Desktop\electron
> node index.js
module.js:471
throw err;
^
Error: Cannot find module 'app'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Administrator\Desktop\electron\index.js:1:73)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! breef#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the breef#1.0.0 start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the breef package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs breef
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls breef
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Administrator\Desktop\electron\npm-debug.log
Here is my package.json:
{
"name": "breef",
"version": "1.0.0",
"description": "A simple chat application.",
"main": "index.js",
"dependencies": {
"electron": "^1.4.12"
},
"devDependencies": {},
"scripts": {
"test": "breeftestcmd",
"start": "node index.js"
},
"keywords": [
"breef"
],
"author": "Sage & Sh4wn",
"license": "ISC"
}
Here is my index.js:
var app = require("app")
var browserWindow = require("browser-window")
app.on('ready', function() {
var mainWindow = new browserWindow({
width: 800,
height: 600
})
mainWindow.loadUrl('http://google.com');
})
If app is a module, it's missing in your package.json. If not, you should use a path to require it
var app = require('./app');
The guide you followed is out of date, as of Electron v1.0.0 the way built-in Electron modules are imported has changed. This is the correct way:
const {app, BrowserWindow} = require("electron")
You may also find it beneficial to read the previous question that covered this topic: What's the proper way to require in Node.js?
I'm trying to run voxel-hello-world (a Minecraft-like game, which runs in the browser). I get the following error when I try to access the page at localhost:
4 verbose stack Error: voxel-hello-world#0.6.0 start: `beefy test.js:bundle.js 8080`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:242:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:852:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Details (incl. npm-debug.log) can be found here.
I have no experience with Node.js. My suspicion was that the version of Node.js may be compatible with this code, which AFAIK was written couple of years ago. I tried several older versions of Node.js with the same result.
How can I fix this error? What is it root cause?
Update 1: When I run beefy test.js:bundle.js, I get this:
C:\dev\voxel-hello-world>beefy test.js:bundle.js 8080
module.js:457
throw err;
^
Error: Cannot find module 'C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at setupBrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\bundlers\browserify.js:6:19)
at onlocalbrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\setup-bundlers.js:30:5)
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:42:21
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:121:35
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:93:39
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:59:30
I tried to install browserify...
C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm install browserify -g
C:\Users\pisarenko\AppData\Roaming\npm\browserify -> C:\Users\pisarenko\AppData\Roaming\npm\node_modules\browserify\bin\cmd.js
C:\Users\pisarenko\AppData\Roaming\npm
`-- browserify#13.1.0
But then the same error came.
Update 2: Changing the port to 8085 doesn't help.
C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm start
> voxel-hello-world#0.6.0 start C:\Users\pisarenko\Documents\dev\voxel-hello-world
> beefy test.js:bundle.js 8085
listening on 8085
using .\node_modules\.bin\browserify
200 75ms 1.08KB /index.html
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\.bin\browserify ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
at onErrorNT (internal/child_process.js:348:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.4.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! voxel-hello-world#0.6.0 start: `beefy test.js:bundle.js 8085`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the voxel-hello-world#0.6.0 start script 'beefy test.js:bundle.js 8085'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the voxel-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! beefy test.js:bundle.js 8085
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs voxel-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls voxel-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\pisarenko\Documents\dev\voxel-hello-world\npm-debug.log
C:\Users\pisarenko\Documents\dev\voxel-hello-world>
Update 3: Running
npm install beefy
npm install browserify
doesn't help.
Update 4: Here's the contens of the directory voxel-hello-world\node_modules\.bin\.
Update 5: According to the output of npm --verbose start npm tries to execute the command beefy test.js:bundle.js 8085:
C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm --verbose start
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli '--verbose',
npm verb cli 'start' ]
npm info using npm#3.10.3
npm info using node#v6.4.0
npm verb run-script [ 'prestart', 'start', 'poststart' ]
npm info lifecycle voxel-hello-world#0.6.0~prestart: voxel-hello-world#0.6.0
npm info lifecycle voxel-hello-world#0.6.0~start: voxel-hello-world#0.6.0
voxel-hello-world#0.6.0 start C:\Users\pisarenko\Documents\dev\voxel-hello-world
beefy test.js:bundle.js 8085
When I try to run that command myself, it can't find file C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js, which doesn't exist in that directory (see screenshot below).
C:\Users\pisarenko\Documents\dev\voxel-hello-world>beefy test.js:bundle.js 8085
module.js:457
throw err;
^
Error: Cannot find module 'C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at setupBrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\bundlers\browserify.js:6:19)
at onlocalbrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\setup-bundlers.js:30:5)
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:42:21
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:121:35
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:93:39
at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:59:30
Quick workaround: edit voxel-hello-world/node_modules/beefy/index.js, replace this line (line 64?):
bfy = spawn(browserify_path, args)
with
bfy = spawn(browserify_path, args, {shell: true})
, then npm start, open it in chrome
I reproduced same error with following commands in git bash:
$ git clone https://github.com/maxogden/voxel-hello-world
$ cd voxel-hello-world/
$ npm -v
3.3.6
$ node -v
v6.1.0
$ cmd /c ver
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
> exit
$ npm i
$ npm start
beefy spawns command line browserify without shell, this works on Linux since node_modules/.bin/browserify is a valid executable. But Windows can't execute it.
Adding the options {shell: true} is to start a shell (cmd.exe) and run the command in it, browserify resolves to the batch file browserify.cmd in the shell.
Global installation of browserify or other packages are not required, npm start and other npm scripts automatically adds executable of local packages to PATH.