ReferenceError: remote is not defined-- Evolus Pencil development - javascript

I have downloaded Pencil-development, but cannot get it to run in VSCode. Message is coming from electron\resources\default_app.asar\main.js during loadApplicationPackage.
Any help getting this to run under VScode is appreciated.
tkx, Paul
==>VSCode-About
VisualStudioCode--Version: 1.74.3 (system setup)
Date: 2023-01-09T16:59:02.252Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No
==> launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "C:\\H_Paul\\Pencil\\electron-v22.0.3-win32-x64",
"env": {
"Path": "C:\\H_Paul\\Pencil\\electron-v22.0.3-win32-x64\\node_modules\\app\\.bin;${env:Path}"
},
"runtimeExecutable": "C:\\H_Paul\\Pencil\\electron-v22.0.3-win32-x64\\electron.exe",
"args" : ["C:\\H_Paul\\Pencil\\pencil-development\\app\\app.js"],
"outputCapture": "std"
}
]
}
==> debug console
C:\H_Paul\Pencil\electron-v22.0.3-win32-x64\electron.exe C:\H_Paul\Pencil\pencil-development\app\app.js
Debugger listening on ws://127.0.0.1:61905/92a1894d-8337-4202-be16-ce48bcbed975
Debugger attached.
App threw an error during load
ReferenceError: remote is not defined
at Object.<anonymous> (C:\H_Paul\Pencil\pencil-development\app\app.js:16:24)
==>app.js the offending line of code
16 const dialog = remote.dialog;

Related

Electron-builder Tray Icon not showing up (Linux Mint 20, electronjs 11, electron-builder 22)

So i have this very simple electron.js test-project which works fine with npm start:
const { app, nativeImage } = require('electron');
const electron = require('electron');
const path = require('path');
const Tray = electron.Tray
const iconpath = path.join(__dirname, './logo_transparent_white_512x512.png')
app.on('ready', function(){
icon = nativeImage.createFromPath(iconpath);
icon = icon.resize({ width: 16, height: 16})
new Tray(icon);
console.log('ready');
})
The package.json looks like this:
{
"name": "electronbuilder",
"version": "1.0.2",
"description": "dadlu",
"main": "main.js",
"homepage": "www.test.com",
"dependencies": {
"path": "^0.12.7"
},
"devDependencies": {
"electron": "^11.1.1",
"electron-builder": "^22.9.1"
},
"scripts": {
"start": "electron .",
"dist": "electron-builder"
},
"author": "test-author",
"license": "ISC",
"build": {
"appId": "com.elecctron.builder",
"productName": "testBuild",
"linux": {
"target": [
"deb"
],
"maintainer": "test-maintainer",
},
"deb": {
"depends": [
"libappindicator1",
"libnotify4"
]
},
"extraFiles": [
"./logo_transparent_white_512x512.png"
]
}
}
After running:
yarn dist
and waiting a minute, I can install the package. But running it doesn't do anything.
when enabling the console ('add to desktop', 'open with Text Editor', 'Terminal=true') I can observe, that the app started successfully:
console.log('ready') got executed
I tried all sorts of ways to get the tray icon to work, stubbing across the weirdest things. F.e. when building the Icon like this:
tray = new Tray(./logo_transparent_white_512x512.png);
it does work with npm start, but after yarn dist, nothing happends. Though, going into the applications folder and running
$ ./{name}
it starts up fine, including the tray icon. (./logo_transparent_white_512x512.png isn't 512x512, i already resized it to 256x256)
its cant be an lib problem either, because this project can be build fine on my system.
I hope someone can help me, ive got my first real project ready, but can only start it with npm start. Any attempts to build it fail, meaning the tray icon doesn't show up.
If some information is missing, feel free to ask.

Sonarqube jest coverage report fails on expected XML format

I am using jest-sonar-reporter for the coverage as below:
package.json
{
"name": "app",
"version": "1.0.0",
"description": "The task runner packages for Gulp",
"main": "gulpfile.js",
"scripts": {
...
"test": "jest --coverage",
...
},
"devDependencies": {
...
"jest": "26.0.1",
"jest-sonar-reporter": "2.0.0",
...
},
"jest": {
...
"collectCoverage": true,
"testResultsProcessor": "jest-sonar-reporter"
},
"jest-junit": {
"suiteName": "jest tests",
...
}
}
I have the test-report.xml file generated after npm run test as below:
test-report.xml
<?xml version="1.0" encoding="UTF-8"?>
<testExecutions version="1">
<file path="<path to>\AreaList.test.jsx">
<testCase name="Description 1 " duration="6"/>
</file>
<file path="<path to>\selectors.search.test.js">
<testCase name="Description 2 " duration="2"/>
</file>
</testExecutions>
SonarScanner command:
sonar-scanner.bat -Dsonar.host.url="http://localhost:9000" -Dsonar.projectKey="Project-A" -Dsonar.projectName="Project-A" -Dsonar.sourceEncoding=UTF-8 -Dsonar.testExecutionReportPaths="\test-report.xml"
I am getting error as:
INFO: Parsing <path to>\test-report.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 5:29.011s
INFO: Final Memory: 15M/68M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of generic test execution report '<path to>\test-report.xml'. Look at the SonarQube documentation to know the expected XML format.
ERROR: Caused by: Line 3 of report refers to a file which is not configured as a test file: <path to>\AreaList.test.jsx
Am I missing any configuration?
Appreciate your response. Thank you.

Node error 'Cannot find module' when running test case

I'm new to node and nightwatch and I have followed all the Getting Started instructions from Installing node, npm, selenium stand alone, starting the selenium driver, I downloaded the chrome driver as well and have it in the same directory. I have created the conf file and a simple test case js. When I go to run the test case through Node Command Line, I keep getting an error:
Error: Cannot find module 'C:\Users\x203946\tests'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
Nightwatch.js
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "globals",
"selenium": {
"start_process": true,
"server_path": "node_modules/selenium-standalone/.selenium/selenium-
server/",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "https://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
Nightwatch.conf.js
require('babel-core/register');
const fs = require("fs");
module.exports = ((settings) => {
const seleniumFileName =
fs.readdirSync("node_modules/selenium-standalone/.selenium/selenium-
server/");
settings.selenium.server_path += seleniumFileName;
return settings;
})(require("./nightwatch.json"));
Test
module.exports = {
'Does not show the task list if there are no tasks'(client) {
client
.url('http://todomvc.com/examples/react/#/')
.waitForElementVisible('.header h1')
.expect.element('.main').to.not.be.present;
client.end();
},
You specified "tests" in Nightwatch.js but test file is in "test" directory so a rename of the directory "test" to "tests" would at least fix that. Also, ,I think you should name the config file nightwatch.json

Can not launch TypeScript project

Recently I switched to using Gulp. After struggling a bit I finally managed to succeed compiling my project. Now, I can't launch it, VS Code tells me this:
Cannot launch program '../src/bootstrap.ts'; setting the 'outFiles' attribute might help.
When I use tsc to compile and run the app, everything works fine.
Here are my config files:
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "build",
"sourceMaps": true,
"program": "${workspaceRoot}/src/bootstrap.ts",
"outFiles": ["${workspaceRoot}/lib/**/*.js"],
"cwd": "${workspaceRoot}"
}
]
}
tasks.json:
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "build",
"isBuildCommand": true,
"showOutput": "always",
"problemMatcher": "$tsc"
}
]
}
gulpfile.js:
var gulp = require('gulp')
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('copy', function () {
var copyResult = gulp.src('src/templates/*.hbs')
.pipe(gulp.dest('lib/templates/'));
return copyResult;
});
gulp.task('compile', function () {
var tsResult = gulp.src('src/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts({
module: "commonjs",
target: "es6",
noImplicitAny: false,
typeRoots: ["node_modules/#types"],
declaration: true,
experimentalDecorators: true,
emitDecoratorMetadata: true
}));
return tsResult.js
.pipe(sourcemaps.write('.', { sourceRoot: function (file) { return file.cwd + '/lib'; } }))
.pipe(gulp.dest('lib'));
});
gulp.task('build', ['copy', 'compile']);
And here is the project folder structure:
- lib (compiled output)
- api
- engine
- src
- api
- engine
- bootstrap.ts
- gulpfile.js
- tsconfig.json
So I can't find what's wrong with the outFiles setting.
EDIT
Ok, I guess I've found what's going on.
This is the js.map file generated by tsc (mapping attribute omitted) :
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[]}
And this is the js.map file that gulp generates (mapping and sourceContent omitted):
{"version":3,"sources":["bootstrap.ts"],"names":[]}
The difference is the obvious absence of relative folder path in the sources property. So when I compile with gulp, VSCode can't find the .ts files. So I guess I have to find a way to compile all the files just like tsc does with gulp.
Ok got it!
Adding the code below just before sourcemaps.write() fixes the problem.
.pipe(sourcemaps.mapSources(function (sourcePath, file) {
// source paths are prefixed with '../src/'
return '../src/' + sourcePath;
}))

Webpack: ERROR in ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js Module not found: Error: Cannot resolve 'file' or 'directory' ../package

I want to use Webpack on my projects, but when I run
npm run dev
, I get this error.
ERROR in ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js Module not
found: Error: Cannot resolve 'file' or 'directory' ../package in
/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/sqlite3/node_modules/node-pre-gyp/lib
# ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js 60:16-37
ERROR in ./~/sqlite3/~/node-pre-gyp/lib/info.js Module not found:
Error: Cannot resolve module 'aws-sdk' in
/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/sqlite3/node_modules/node-pre-gyp/lib
# ./~/sqlite3/~/node-pre-gyp/lib/info.js 14:14-32
ERROR in ./~/sqlite3/~/node-pre-gyp/lib/publish.js Module not found:
Error: Cannot resolve module 'aws-sdk' in
/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/sqlite3/node_modules/node-pre-gyp/lib
# ./~/sqlite3/~/node-pre-gyp/lib/publish.js 17:14-32
ERROR in ./~/sqlite3/~/node-pre-gyp/lib/unpublish.js Module not found:
Error: Cannot resolve module 'aws-sdk' in
/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/sqlite3/node_modules/node-pre-gyp/lib
# ./~/sqlite3/~/node-pre-gyp/lib/unpublish.js 15:14-32
ERROR in ./~/sqlite3/~/rc/index.js Module build failed: Error: Parse
Error: Line 1: Unexpected token ILLEGAL
at throwError (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2823:21)
at scanPunctuator (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:1011:9)
at advance (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:1747:16)
at peek (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:1773:21)
at parseProgram (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6535:9)
at Object.parse (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/node_modules/esprima-fb/esprima.js:7713:23)
at getAstForSource (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/src/jstransform.js:244:21)
at Object.transform (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/src/jstransform.js:267:11)
at Object.transform (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/node_modules/jstransform/src/simple.js:105:28)
at Object.module.exports (/Users/caizongming/Flowerhop/-DBLab-Alarm-Project-/Server/node_modules/jsx-loader/index.js:15:31)
# ./~/sqlite3/~/node-pre-gyp/lib/info.js 11:13-26
This is my WEBPACK.CONFIG.js
var path = require ('path');
module.exports = {
entry: './server.js',
output: {
filename: 'bundle.js'
},
module: {
loaders:[
{ test: /\.css$/, loader: "style!css" },
{ test: /\.js$/, loader: 'jsx-loader?harmony' },
{ test: /\.json$/, loader: 'json-loader' }
]
},
resolve: {
fallback: path.join(__dirname, "node_modules"),
extensions : ['', '.js', '.jsx']
},
resolveLoader: { fallback: path.join(__dirname, "node_modules") },
target: 'node'
};
This is package.json.
{
"name": "biocenter",
"version": "1.0.0",
"description": "",
"main": "server.js",
"directories": {
"test": "test"
},
"dependencies": {
"body-parser": "^1.15.0",
"express": "^4.13.4",
"request": "^2.72.0",
"sqlite3": "^3.1.4",
"querystring": "^0.2.0",
"should": "^8.3.2"
},
"devDependencies": {
"brfs": "^1.4.3",
"json-loader": "^0.5.4",
"mocha": "^2.4.5",
"transform-loader": "^0.2.3",
"webpack": "^1.13.1"
},
"scripts": {
"test": "mocha",
"start": "node server.js",
"dev": "webpack-dev-server --devtool eval --progress --colors",
"deploy": "NODE_ENV=production webpack -p"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FlowerHop/-DBLab-Alarm-Project-.git"
},
"author": "Flowerhop",
"license": "ISC",
"bugs": {
"url": "https://github.com/FlowerHop/-DBLab-Alarm-Project-/issues"
},
"homepage": "https://github.com/FlowerHop/-DBLab-Alarm-Project-#readme"
}
Can anybody help me fix this problem?
I encountered the similar problem with the lzma-native, which also uses node-pre-gyp. The problem is they all directly require the node-pre-gyp in the module. I try to replace the line of code that use node-pre-gyp
var nodePreGyp = require('node-pre-gyp');
var path = require('path');
var binding_path = nodePreGyp.find(path.resolve(path.join(__dirname,'./package.json')));
var native = require(binding_path);
into
var native = require('pre-gyp-find')('lzma_native');
// notice that the parameter here is the binary module name in package.json of lzma-native
And that finally works for me. Though, this solution requires us to modify the source code, and add an additional dependency 'pre-gyp-find'. Maybe you could send a PR to author about this.
This is not the best solution, since it doesn't actually solve but avoid the problem.
I noticed everything seems right during npm install, but actually there is some error during install. My problem was fixed with npm install sqlite3 --build-from-source.

Categories