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?
Related
PS C:\Users\PC1\Downloads\portfolio_website-STARTER> npm start
> portfolio_website-starter#1.0.0 start C:\Users\PC1\Downloads\portfolio_website-STARTER
> node index.js
internal/modules/cjs/loader.js:892
throw err;
^
Error: Cannot find module 'C:\Users\PC1\Downloads\portfolio_website-STARTER\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! portfolio_website-starter#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the portfolio_website-starter#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
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\PC1\AppData\Roaming\npm-cache\_logs\2021-09-05T22_40_19_833Z-debug.log
PS C:\Users\PC1\Downloads\portfolio_website-STARTER>
The error shown above happens when I try to run npm start to start the virtual host.
I have tried the following:
Updated node.js to the latest version.
Went to package.json under scripts and added "start": "node index.js".
first, do you install the dependencies? (npm i)
Then, exists index.js file in the portfolio_website-STARTER folder?
First make sure your startup file is index.js in your package.json file and make sure you have index.js in your project.
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 am trying to test the Microsoft BotBUilder samples with the Bot Framework Emulator.
I have cloned the BotBuilder repo and gone through the readme instructions npm install but when I run npm start I get this error
/home/ronald/Desktop/botbuilder-samples/samples/javascript_nodejs/02.echo-bot/node_modules/csv-parse/lib/index.js:20
super({...{readableObjectMode: true}, ...opts})
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ronald/Desktop/botbuilder-samples/samples/javascript_nodejs/02.echo-bot/node_modules/csv/lib/index.js:6:10)
npm ERR! Linux 4.15.0-72-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v7.10.1
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! echobot#1.0.0 start: `node ./index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the echobot#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 echobot 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 echobot
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls echobot
npm ERR! There is likely additional logging output above.
Your running it on Nodejs version 7+ and BotBuilder require 10.14+.
So your node is not able to understand deconstructing operator ....
Try to upgrade your node and it'll works fine.
Can you please try:
super({readableObjectMode: true, ...opts})
I don't think you need to spread the first object.
I'm getting 'Error: Cannot find module '../scripts/start' from projects set up using create-react-app that previously worked fine, now when i run 'npm start' i'm getting this error - the only workaround seems to be rm -rf node_modules followed by npm install, but next day I run into the same problem. Any ideas how to fix this please (see full error message below) - thanks.
>react-scripts start
module.js:549
throw err;
^
Error: Cannot find module '../scripts/start'
at Function.Module._resolveFilename (module.js:547:15)
at Function.resolve (internal/module.js:18:19)
at Object.<anonymous> (/Users/DANTHORY/Dropbox/card-slider-challenge_TESTING/node_modules/.bin/react-scripts:28:25)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! card-slider-challenge#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the card-slider-challenge#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
package.json:
{
"name":"card-slider-challenge",
"version":"0.1.0",
"private":true,
"scripts":{
"start":"react-scripts start",
"build":"react-scripts build",
"test":"jest",
"eject":"react-scripts eject",
"start-api":"json-server --port 3001 --watch --static none data/db.json"
},
"dependencies":{
"react":"^16.3.2",
"react-dom":"^16.3.2",
"react-slick":"^0.23.2"
},
"devDependencies":{
"jest":"^24.0.0",
"json-server":"^0.12.2",
"react-scripts":"^1.1.4"
}
}
I had the exact same issue and I did the following:
Delete node_modules folder
Run npm install
It fixed my issue, but what it caused, I don't know.
I changed my computer and I clone my projet from Github
Delete node_modules folder
Run npm install
I stumbled upon this error when trying to start my application via NPM start. I am not sure where the problem lies, because it worked fine in my other computer (I unzip the file to this computer ran, npm install just in case and then tried to start it, but then the following error is thrown below).
Any help would be appreciated.
module.js:340
throw err;
^
Error: Cannot find module './'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/mnt/c/Users/Jonathan/Desktop/client/<NAME>/node_modules/.bin/electron:3:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v0.10.46
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! <NAME>#0.0.0 start: `electron main.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the <NAME>#0.0.0 start script 'electron main.js'.
npm ERR! This is most likely a problem with the <NAME> package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! electron main.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs <NAME>
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls <NAME>
npm ERR! There is likely additional logging output above.
package.json
{
"name": "<NAME>",
"version": "0.0.0",
"description": "[..]",
"main": "index.js",
"build": {
"appId": "test.321",
"app-category-type": "your.app.category.type",
"win": {
"iconUrl": "http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png"
}
},
"scripts": {
"start": "electron main.js",
"postinstall": "install-app-deps",
"pack": "build --dir",
"dist": "build"
},
"author": "john#gmail.com>",
"license": "ISC",
"devDependencies": {
"electron": "^1.3.3",
"electron-installer-squirrel-windows": "^1.3.0",
"electron-packager": "^7.5.1"
}
}
UPDATE
After solving the above error, the following error is thrown
I am running this through bash on windows 10, and have tried to install all required libraries to get the electron app to start via npm start on windows (works fine in my ubuntu)
electron main.js
[8002:0814/084446:FATAL:render_sandbox_host_linux.cc(40)] Check failed: 0 == shutdown(renderer_socket_, SHUT_RD). shutdown: Invalid argument
#0 0x000001e098ce <unknown>
#1 0x000001e1f4db <unknown>
#2 0x000001e1fa9d <unknown>
#3 0x000002892fc2 <unknown>
#4 0x00000265e599 <unknown>
#5 0x000002664b5f <unknown>
#6 0x00000265dc36 <unknown>
#7 0x000001204157 <unknown>
#8 0x000001202c30 <unknown>
#9 0x0000033a9470 main
#10 0x7fe5ec701f45 __libc_start_main
#11 0x000000575039 <unknown>
The shutdown check fail is a known issue. Electron runs just fine as a native Windows app, so just do that instead of over-complicating things with Bash on Windows.