I have built an electron app that uses tensorflow and opencv4nodejs.
The app works well when I use npm start. However, when I try to build my app, it bombs out with the following error:
The issue here is that I have not built the opencv4nodejs from source. Instead I manually installed opencv and then disabled autobuild to install it for my app.
From the error, I see that it is looking for a lib directory under opencv-build but it is simply not there.
Is there a way to NOT have anything rebuilt since I already have all the modules built for Windows 10?
Am sure this is something simple but have run up against a brick wall for this.
Here is my package.json
`
{
"name": "myApp",
"version": "0.0.1",
"description": "My Electron App",
"main": "main.js",
"license": "abc",
"private": true,
"scripts": {
"postinstall": "install-app-deps",
"start": "electron .",
"build": "electron-packager . nGage --platform win32 --arch x64 --out dist/ --icon image/nGage-Icon.ico --overwrite",
"setup": "electron-installer-windows --src dist/nGage-win32-x64/ --dest dist/installers/ --config config.json --overwrite",
"dist": "build"
},
"build": {
"appId": "com.electron.app",
"publish": [
{
"provider": "generic",
"url": "abc"
}
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
],
"certificateFile": "cert/abc",
"certificatePassword": "xyz"
},
"asar": false,
"nsis": {
"oneClick": true,
"perMachine": false,
"artifactName": "${productName}-Setup-${version}-x64.${ext}"
}
},
"author": {
"name": "ABC",
"email": "xyz#abc.com",
"url": "www.abc.com"
},
"devDependencies": {
"electron": "^9.0.3",
"electron-builder": "^19.53.6",
"electron-installer-windows": "^0.2.0",
"electron-packager": "^8.5.2",
"electron-winstaller": "^2.5.2",
"grunt-electron-installer": "^2.1.0"
},
"dependencies": {
"#tensorflow/tfjs": "^2.0.0",
"#tensorflow/tfjs-node": "^2.0.0",
"auto-launch": "^5.0.1",
"cron": "^1.2.1",
"electron-config": "^0.2.1",
"electron-positioner": "^3.0.0",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^2.19.0",
"electron-window": "^0.8.1",
"graceful-fs": "^4.1.11",
"homedir": "^0.6.0",
"https": "^1.0.0",
"opencv4nodejs": "^5.6.0",
"request": "^2.88.2",
"url": "^0.11.0",
"username": "^3.0.0",
"util": "^0.12.3",
"windows-build-tools": "^5.2.2"
}
}
`
Any insights will be most helpful!
Thanks,
Arun
So I realised that I needed to set the following environment variables before doing npm run build
since I had used them while build opencv4nodejs. Here is what I have taken from the the opencv4nodejs site.
`
Installing OpenCV Manually
Setting up OpenCV on your own will require you to set an environment variable to prevent the auto build script to run:
# linux and osx:
export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
# on windows:
set OPENCV4NODEJS_DISABLE_AUTOBUILD=1
Windows
You can install any of the OpenCV 3 or OpenCV 4 releases manually or via the Chocolatey package manager:
# to install OpenCV 4.1.0
choco install OpenCV -y -version 4.1.0
Note, this will come without contrib modules. To install OpenCV under windows with contrib modules you have to build the library from source or you can use the auto build script.
Before installing opencv4nodejs with an own installation of OpenCV you need to expose the following environment variables:
OPENCV_INCLUDE_DIR pointing to the directory with the subfolder opencv2 containing the header files
OPENCV_LIB_DIR pointing to the lib directory containing the OpenCV .lib files
Also you will need to add the OpenCV binaries to your system path:
add an environment variable OPENCV_BIN_DIR pointing to the binary directory containing the OpenCV .dll files
append ;%OPENCV_BIN_DIR%; to your system path variable
`
Related
I have 4 packages in my package.json:
"#CT/package-1": "*",
"#CT/package-2": "*",
"#CT/package-3": "*",
"#CT/package-4": "*",
All four packages are not on the NPM registry, but locally linked.
In each package directory I did:
sudo npm link
After that I went into my main project and linked all packages like so:
npm link #CT/package-1
npm link #CT/package-2
npm link #CT/package-3
npm link #CT/package-4
For each command it outputs the linked chain of the sym-links, I checked the paths of each one, and it's correct. If I go in the node_modules folder of my main project and follow #CT/package-X I will end up in my local package directory.
Now I expect that I can run npm i on my main project and it won't try to install those packages from the npm registry. This works for package 2-4, but it does not work for package-1:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/#CT%2fpackage-1 - npm package "package-1" does not exist under owner "CT"
As soon as I remove "#CT/package-1": "*", from my package.json, npm i will success, because it seems to right-fully skip package 2-4, just not package-1.
Now I inspected all four package projects, and it makes no sense to me. All projects compile, all package.json contain the correct package name. Here is the package.json of my first faulty package:
{
"name": "#CT/package-1",
"version": "0.0.2",
"description": "",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
"dist/"
],
"author": "martin-braun",
"license": "ISC",
"keywords": [
"capacitor",
"plugin",
"native"
],
"scripts": {
"lint": "npm run prettier -- --check",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"build": "npm run prettier && npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"#capacitor/android": "^3.0.0",
"#capacitor/core": "^3.0.0",
"#capacitor/docgen": "^0.0.18",
"#ionic/eslint-config": "^0.3.0",
"#ionic/prettier-config": "^1.0.1",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"typescript": "~4.0.3"
},
"peerDependencies": {
"#capacitor/core": "^3.0.0"
},
"prettier": "#ionic/prettier-config",
"eslintConfig": {
"extends": "#ionic/eslint-config/recommended"
},
"capacitor": {
"android": {
"src": "android"
}
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/CT"
},
"dependencies": {}
}
.npmrc
registry=https://npm.pkg.github.com/#CT
registry=https://registry.npmjs.org
When I linked the project on my main project it shew the right paths (i.e.)
/Users/mb/Projects/CT/MAIN/node_modules/#CT/package-1 -> /Users/mb/node_module_collections/ekol/lib/node_modules/#CT/package-1 -> /Users/mb/Projects/CT/package-1
What could I try to find the issue? Again, package 2-4 won't cause npm i to fail, but package.json and npmrc look similar. I'm thankful for any advice.
node v13.12.0
According to errors I faced with this TS/Node project (for a simple TypeScript only REST API) the suggested fix (mentioned here (https://github.com/heineiuo/rippledb/issues/148)) is that I needed something like Node v14.x
I initially jumped all the way v18.x and that tutorial project built and worked. https://www.mongodb.com/compatibility/using-typescript-with-mongodb-tutorial
However, Node 18.x and even downgrading to Node v14.15.5 breaks the build apk and browser processes in one ionic 3 project with the following ionic configuration.
$ ionic info
Ionic:
Ionic CLI : 6.13.1 (C:\Users\AXM\AppData\Roaming\npm\node_modules\#ionic\cli)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 11.0.0
Cordova Platforms : android 10.1.2, browser 5.0.3
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)
Utility:
cordova-res : 0.15.3
native-run : not installed
System:
Android SDK Tools : 26.1.1 (C:/Users/AXM/AppData/Local/Android/Sdk)
NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10 ...really 11 :)
The initial complaints I did not log I believe where about sass failing.
Googling I run into this post though not specifically about "ionic 3" saying downgrade.
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (88)
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"watch": "ionic-app-scripts watch && beep ",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build",
"run:after": "beep",
"serve:after": "beep",
"beep": "bash.exe beep.sh",
"beep0": "bash.exe -c \"echo -en '\\a' \" ",
"releasePWA": "ionic cordova build browser --prod --release"
},
"dependencies": {
"#angular/common": "5.0.3",
"#angular/compiler": "5.0.3",
"#angular/compiler-cli": "5.0.3",
"#angular/core": "5.0.3",
"#angular/forms": "5.0.3",
"#angular/platform-browser": "^5.0.3",
"#angular/platform-browser-dynamic": "5.0.3",
"#ionic-native/android-full-screen": "^4.20.0",
"#ionic-native/app-version": "^4.20.0",
"#ionic-native/clipboard": "^4.20.0",
"#ionic-native/core": "4.5.2",
"#ionic-native/document-viewer": "^4.7.0",
"#ionic-native/file": "^4.7.0",
"#ionic-native/file-transfer": "^4.7.0",
"#ionic-native/in-app-browser": "4.5.2",
"#ionic-native/ionic-webview": "^5.36.0",
"#ionic-native/social-sharing": "4.5.2",
"#ionic-native/splash-screen": "^4.7.0",
"#ionic-native/status-bar": "4.5.2",
"#ionic-native/toast": "4.6.0",
"#ionic/pro": "1.0.16",
"#ionic/storage": "2.1.3",
"#types/youtube": "0.0.46",
"archiver": "^5.3.1",
"child_process": "^1.0.2",
"clipboard-js": "0.3.3",
"com.verso.cordova.clipboard": "https://github.com/VersoSolutions/CordovaClipboard.git",
"cordova-browser": "5.0.3",
"cordova-clipboard": "~1.0.0",
"cordova-plugin-device": "1.1.4",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-fullscreen": "^1.2.0",
"cordova-plugin-inappbrowser": "~1.7.1-dev",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-x-socialsharing": "~5.1.6",
"cordova-plugin-x-toast": "~2.6.0",
"cordova-sqlite-storage": "~2.0.3",
"danielsogl-cordova-plugin-clipboard": "1.0.2",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "~2.2.1",
"ionicons": "3.0.0",
"node-apk": "^1.1.1",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"url-exist": "^3.0.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"#ionic/app-scripts": "^3.2.4",
"#types/node": "^9.6.61",
"cordova-android": "^10.1.2",
"cordova-plugin-apkupdater": "^4.0.0",
"cordova-plugin-app-version": "^0.1.14",
"cordova-plugin-ionic-webview": "^4.1.3",
"tslint": "^5.10.0",
"tslint-ionic-rules": "0.0.16",
"typescript": "^2.8.3",
"viewport-units-buggyfill": "0.6.2"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"cordova-plugin-x-socialsharing"
],
"cordovaPlatforms": [
{
"platform": "android",
"version": "",
"locator": "android"
},
{
"platform": "browser",
"version": "",
"locator": "browser"
}
],
"description": "UPS.ion: project",
"config": {
"ionic_source_map": "source-map",
"ionic_copy": "./copy.config.js"
},
"cordova": {
"plugins": {
"cordova-sqlite-storage": {},
"cordova-plugin-x-toast": {},
"cordova-clipboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"com.verso.cordova.clipboard": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-fullscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-apkupdater": {},
"cordova-plugin-app-version": {}
},
"platforms": [
"browser"
]
}
}
Anyway I am poor at resolving issues like these here is my package.json I am not back to Node v10.16.0, not fully recovered with some weird new issues when I build
ionic cordova build browser --prod --release
I get
> ionic-app-scripts.cmd build --prod --target cordova --platform browser
[07:44:15] ionic-app-scripts 3.2.4
[07:44:15] build prod started ...
[07:44:15] clean started ...
[07:44:15] clean finished in 2 ms
[07:44:15] copy started ...
[07:44:15] deeplinks started ...
[07:44:15] deeplinks finished in 293 ms
[07:44:15] ngc started ...
[07:44:20] typescript error
Invalid provider for the NgModule 'AppModule in S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/src/app/app.module.ts' -
only instances of Provider and Type are allowed, got: [[object Object], Clipboard in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/#ionic-native/clipboard/index.d.ts, Toast in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/#ionic-native/toast/index.d.ts, SocialSharing in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/#ionic-native/social-sharing/index.d.ts, AndroidFullScreen in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/#ionic-native/android-full-screen/index.d.ts, ?null?]
[07:44:20] ionic-app-script task: "build"
[07:44:20] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
at S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\#ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\#ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\#ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\#ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[ERROR] An error occurred while running subprocess ionic-app-scripts.
ionic-app-scripts.cmd build --prod --target cordova --platform browser exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
I have googled among many other things
Invalid provider for the NgModule 'AppModule
Error: The Angular AoT build failed
and made many guess work attempts (npm uninstall this... npm install that...).
I also cleaned all lint errors, but it did not help either.
Funny but deleting the 5 providers list shown below lines 120..124 in app.modules.ts makes the build happy but the browser build won't run and the same with the APK build.
[![enter image description here][1]][1]
Perhaps there is something else that needs to be upgraded to make it possible to have a newer version of node that works for both projects (I can't afford to loose my ionic3 project).
Sorry it's complicated...
Using different versions of Node to run each app might help. The tool NVM is great for this, go ahead and install it if you haven't already.
In one shell, install your newer Node version, e.g. nvm install lts/gallium and nvm use lts/gallium. Wipe out node_modules and reinstall dependencies (rm -rf ./node_modules && npm i) and run your server stuff there.
In another shell, install the older Node version, e.g. nvm install lts/erbium and nvm use lts/erbium. Again, wipe out node_modules and reinstall dependencies (rm -rf ./node_modules && npm i) and run your Ionic 3 project there.
If that doesn't help, putting a gutted version of your app on Github with instructions to replicate the bug would best enable further debugging.
As the title says, node cannot find main.js. I am doing this through replit and my .replit file is run = "npm test". My package.json file is
{
"name": "Adventure",
"version": "1.0.0",
"description": "This is The Adventure Bot By BrainDead_Dev",
"main": "main.js",
"dependencies": {
"#replit/database": "^2.0.1",
"discord-buttons": "^4.0.0-deprecated",
"discord.js": "^13.6.0",
"moment": "^2.29.1",
"winston": "^3.6.0"
},
"devDependencies": {},
"scripts": {
"test": "main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BrainDeadDev/Adventure.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/BrainDeadDev/Adventure/issues"
},
"homepage": "https://github.com/BrainDeadDev/Adventure#readme"
}
This is for a discord bot, and it has been working perfectly fine up until the point where I wanted to update discord.js and had to reinstall npm. Any help would be appreciated as I am quite lost.
When you updated the discord.js package, it now requires a more current version of node js (v16.6).
To update to the version of node using npm simply run:
npm install -g n
If you are using nvm you can do:
nvm install 16.6
then tell nvm to use the new version:
nvm use 16.6
Then you can check the version you are using by running:
node --version
Edit for Repl.it:
following this blog, you should be able to do it by running this:
npm i --save-dev node#16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
You can also try following this question on repl.it forums
I am trying to deploy a nodejs app onto Azure App Service. I did the basics of deploying it, but it's failing to run. It seems it is designed to run "node run.js" commands rather than "npm run start".
I'm playing in the console, and if I try to run npm run start manually, I get a series of errors tied to build. Basically:
'tsc' is not recognized as an internal or external command
I'm wondering if there's something really obvious here about how tsc (and others) can be added to path. I have to admit, I'm not particularly well versed in using Azure or Node for that matter. Any help would be very much appreciated! Thanks!
This is the package.json file:
{
"name": "test-scraper",
"version": "0.1.1",
"description": "",
"main": "dist/main.js",
"scripts": {
"build": "tsc",
"build:dev": "tsc --watch",
"prestart": "npm run build",
"start:dev": "nodemon",
"start": "pm2 start dist/src/main.js --node-args=\"-r ./tsconfig-paths-bootstrap.js\" && pm2 monit",
"stop": "pm2 delete main"
},
"author": "",
"license": "MIT",
"devDependencies": {
"#types/lodash": "^4.14.161",
"#types/node": "^14.11.8",
"#types/puppeteer": "^3.0.2",
"nodemon": "^2.0.4",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
},
"dependencies": {
"axios": "^0.20.0",
"discord-webhook-node": "^1.1.8",
"lodash": "^4.17.20",
"messaging-api-telegram": "^1.0.1",
"playwright-firefox": "^1.4.2",
"pm2": "^4.5.0",
"tsconfig-paths": "^3.9.0",
"winston": "^3.3.3"
}
}
Run this command locally for installing typescript, because your code is compiled with the tsc command.
npm install -g typescript
Mostly I was following this tutorial.
Add the tsc command to package.json and add the dependencies:
"build": "tsc --project ./"
...
"devDependencies": {
"#types/express": "^4.17.9",
"#types/node": "^14.14.20",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},
Here is my file structure:
I add a empty file.ts and add this scripts to the tsconfig.jason file:
"exclude": [ "src", "wwwroot" ],
"include": [ "file.ts" ]
Deploy through Azure Web App deployment center:
And the app build (tsc) run successfully:
if you are deploying to Production (NODE_ENV: production), devDependencies will no longer being installed, and you need to edit your package.json and move typescript to dependencies.
Source
When deploying an OpenShift node.js project with a depdency on browserify 4.0.0, I get an error installing browserify's dependencies. Specifically:
...
remote: npm ERR! Error: No compatible version found: stream-browserify#'^1.0.0'
remote: npm ERR! Valid install targets:
remote: npm ERR! ["0.0.0","0.0.1","0.0.2","0.0.3","0.0.4","0.1.0","0.1.1","0.1.2","0.1.3","1.0.0"]
...
Given that stream-browserify's version is ^1.0.0 according to browserify's depdency and that openshift is suggesting 1.0.0 is a valid install target, why is this failing? I have seen this error in other cases, whenever the highest available openshift version fits the careted package.json version.
Am I misunderstanding what the caret means? Is this an OpenShift bug?
My package.json:
{
"name": "SampleApp",
"version": "1.0.0",
"description": "do things online",
"keywords": [
"OpenShift",
"Node.js",
"application",
"openshift"
],
"author": {
"name": "J",
"email": "j#email.com",
"url": ""
},
"homepage": "http://www.openshift.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": "0.x",
"npm": "1.x"
},
"dependencies": {
"body-parser": "1.x",
"browserify": "4.0.0",
"cookie-parser": "1.x",
"cookie-session": "1.x",
"express": "4.x",
"fast-csv": "0.x",
"multer": "0.0.5",
"pg": "3.x",
"sql": "0.x",
"xlsx-extract": "0.0.4"
},
"devDependencies": {
},
"bundleDependencies": [],
"private": true,
"main": "server.js",
"scripts": {
"build-js": "browserify public/index.js -o public/index-bundle.js & browserify public/intake.js -o public/intake-bundle.js",
"start": "npm run build-js && node server.js"
}
}
This behaviour could be because of different versions on node and npm on your local machine and openshift environment. Start by fixing "engines" attribute in your package.json, something as below:
"engines": {
"node": ">= 0.10",
"npm": ">= 1.4"
}
If still the issue is there (on openshift) it is due to the unavailability of the nodejs/npm required versions on openshift environment. For example, as of today, on my local machine I may be using node version 0.10.28 and npm version 1.4.9, but on openshift nodejs default cartridge I have to be content with nodejs version 0.10.5 and npm version 1.2.17, which is a big gap.
So, in this case, the easiest way to get around is by using "npm shrinkwrap", which freezes the nested dependency versions that ought to be used, hence doing away with varied behaviour of npm versions to figure out the nested dependency to install.
Can read about shrinkwrap here: https://www.npmjs.org/doc/cli/npm-shrinkwrap.html
So, on your local machine:
run npm install and make sure everything works.
fire npm shrinkwrap This will create a file - "npm-shrinkwrap.json", with the required shrinkwrap info. Add, commit and push the file to the openshift git repo.