React Native - home automation from deepsyx, how to run it? - react-native

I have the experience with ReactJS and I have built the web app with react.
But I have seen the home automation from deepsyx
https://github.com/deepsyx/home-automation
I have tried to run server in "server" directory but it's error
me:server mai$ node index.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'home-config'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/mai/Documents/Workspace/home-automation/server/index.js:13:20)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
How to fix this error?
This project is very cool, Anybody has the step to run this project?
Thanks in advance !!!!
me:server mai$ cat package.json
{
"name": "home-automation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Viktor Kirilov (deepsybg#gmail.com)",
"license": "MIT",
"dependencies": {
"home-config": "file:../home-config",
"home-records": "file:../home-records",
"ws": "1.1.1"
}
}

I've got it to run React Home Automation Server.
I hope this could help all newbie like me to do the home automation on Raspberry Pi.
I found 2 steps:
I found the problem that it cannot find "home-config" directory so I go to "home-config" directory and copy "index.example.js" to "index.js".
In the virtualbox need to add "../" to const homeConfig =
require('../home-config'); from const homeConfig = require('home-config'); but cannot run anyway because of not raspberry pi environment.
I get the error from running temperature sensor "DS18B20", then I fix const deviceFolder = files.find(file => /^10/.test(file)); to const deviceFolder = files.find(file => /^28/.test(file)); in "server/utils/temperature.js" because my raspberry pi 3 generate "28-01131faf1feb directory.

Related

AWS Amplify: How to install sharp in Lambda Trigger?

I am new to using AWS Amplify and AWS Lambda and
I'm facing a problem that I can't solve on my own.
Explanation:
I ran the command:
amplify add storage
This command generated for me the trigger below:
exports.handler = async function (event) {
console.log('Received S3 event:', JSON.stringify(event, null, 2));
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
console.log(`Bucket: ${bucket}`, `Key: ${key}`);
};
What I want to do?
I would like to resize the images that are uploaded to my bucket.
What's the problem?
My problem is that I can't install sharp package.
Because of yarn, I cannot run this command:
npm install sharp
With npm, I get this error (remove package-lock.json file don't resolve the problem):
warning package-lock.json found. Your project contains lock files
generated by tools other than Yarn. It is advised not to mix package
managers in order to avoid resolution inconsistencies caused by
unsynchronized lock files. To clear this warning, remove
package-lock.json.
So I ran this command:
yarn add sharp
But I still have errors.
I created a video that I uploaded to Youtube:
https://youtu.be/iZANbmVhhp4
Also I tested that but it's not works:
↓ ↓ ↓
https://sahanamarsha.medium.com/resizing-s3-images-with-aws-lambda-trigger-ca4cf2372d0e
https://github.com/SahanAmarsha/image-resizer-lambda/blob/master/package.json
↑ ↑ ↑
Creating thumbnails is very common and I don't understand why I can't do it.
Can you explain to me step-by-step how to do it?
So that I can understand why I can't.
Regards
Additional infos
Here is the Execution result:failed Details I get in the AWS console:
{
"errorType": "Error",
"errorMessage": "\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/node_modules/sharp/lib/sharp.js\n- /var/task/node_modules/sharp/lib/constructor.js\n- /var/task/node_modules/sharp/lib/index.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js\n\nPossible solutions:\n- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
"trace": [
"Error: ",
"Something went wrong installing the \"sharp\" module",
"",
"Cannot find module '../build/Release/sharp-linux-x64.node'",
"Require stack:",
"- /var/task/node_modules/sharp/lib/sharp.js",
"- /var/task/node_modules/sharp/lib/constructor.js",
"- /var/task/node_modules/sharp/lib/index.js",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/Runtime.js",
"- /var/runtime/index.js",
"",
"Possible solutions:",
"- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"",
"- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"",
"- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:34:9)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Module.require (internal/modules/cjs/loader.js:974:19)",
" at require (internal/modules/cjs/helpers.js:101:18)",
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:1)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"
]
}
Here is the Log output I get in the AWS console:
the installation documentation: https://sharp.pixelplumbing.com/install","stack":["Error: ","Something went wrong installing the \"sharp\" module","","Cannot find module '../build/Release/sharp-linux-x64.node'","Require stack:","- /var/task/node_modules/sharp/lib/sharp.js","- /var/task/node_modules/sharp/lib/constructor.js","- /var/task/node_modules/sharp/lib/index.js","- /var/task/index.js","- /var/runtime/UserFunction.js","- /var/runtime/Runtime.js","- /var/runtime/index.js","","Possible solutions:","- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"","- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"","- Consult the installation documentation: https://sharp.pixelplumbing.com/install"," at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:34:9)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"," at Module.load (internal/modules/cjs/loader.js:950:32)"," at Function.Module._load (internal/modules/cjs/loader.js:790:12)"," at Module.require (internal/modules/cjs/loader.js:974:19)"," at require (internal/modules/cjs/helpers.js:101:18)"," at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:1)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"]}
2022-10-26T03:30:59.951Z undefined ERROR Uncaught Exception {"errorType":"Error","errorMessage":"\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/node_modules/sharp/lib/sharp.js\n- /var/task/node_modules/sharp/lib/constructor.js\n- /var/task/node_modules/sharp/lib/index.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js\n\nPossible solutions:\n- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install","stack":["Error: ","Something went wrong installing the \"sharp\" module","","Cannot find module '../build/Release/sharp-linux-x64.node'","Require stack:","- /var/task/node_modules/sharp/lib/sharp.js","- /var/task/node_modules/sharp/lib/constructor.js","- /var/task/node_modules/sharp/lib/index.js","- /var/task/index.js","- /var/runtime/UserFunction.js","- /var/runtime/Runtime.js","- /var/runtime/index.js","","Possible solutions:","- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"","- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"","- Consult the installation documentation: https://sharp.pixelplumbing.com/install"," at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:34:9)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"," at Module.load (internal/modules/cjs/loader.js:950:32)"," at Function.Module._load (internal/modules/cjs/loader.js:790:12)"," at Module.require (internal/modules/cjs/loader.js:974:19)"," at require (internal/modules/cjs/helpers.js:101:18)"," at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:1)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"]}
START RequestId: 0df51e26-e55f-42a0-8716-f2507ba7ff78 Version: $LATEST
END RequestId: 0df51e26-e55f-42a0-8716-f2507ba7ff78
REPORT RequestId: 0df51e26-e55f-42a0-8716-f2507ba7ff78 Duration: 2382.57 ms Billed Duration: 2383 ms Memory Size: 128 MB Max Memory Used: 15 MB
Unknown application error occurred
Error
Here is my package.json:
{
"name": "S3Triggeref35961b",
"version": "2.0.0",
"description": "Lambda function generated by Amplify",
"main": "index.js",
"license": "Apache-2.0",
"dependencies": {
"sharp": "^0.31.1"
},
"scripts": {
"amplify:S3Triggeref35961b": "cd amplify/backend/function/S3Triggeref35961b/src && npm install && rm -rf node_modules/sharp && SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux --libc=glibc sharp && cd -"
}
}
Here is my index.js:
const sharp = require("sharp");
exports.handler = async function (event) {
console.log("Hello World!");
};

Why does Express refuse to be installed on Cpanel?

I'm trying to create an application that depends on Express, but Cpanel just won't install it. I've contacted Namecheap, followed all their instruction and tried all kinds of things, but haven't had any success.
This is my package.json file
{
"name": "server",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"axios": "^0.27.2",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.17.2",
"mysql2": "^2.3.3",
"puppeteer": "^15.3.2"
}
}
After running "npm install" and having no apparent errors, I find this in the stderr.log file:
- Error: Cannot find module 'express'
- Require stack:
- /home/<user>/public_html/api/app.js
- /usr/local/lsws/fcgi-bin/lsnode.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/<user>/public_html/api/app.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/<user>/public_html/api/app.js',
'/usr/local/lsws/fcgi-bin/lsnode.js'
]
}
For some reason Express won't install. I've destroyed the application and tried all over again, but the same problem arises.
Node version is 14.18.3.
I'm hoping someone who knows what's going on can help me.

Module is extraneous npm

I've checked that the connect-privkey-to-provider module is in the dependencies. However, it keeps saying Module 'connect-privkey-to-provider' is extraneous npm and cannot find module 'connect-privkey-to-provider'.
What's wrong with my code?
PS C:\Users\1Sun\addition-game-starter> truffle deploy --network
klaytn
Error: Cannot find module 'connect-privkey-to-provider'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\1Sun\addition-game-starter\truffle.js:2:29)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Function.Config.load (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:254:1)
at Function.Config.detect (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:243:1)
at Object.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\commands\migrate.js:35:1)
at Command.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\command.js:101:1)
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:22:1)
at webpack_require (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:19:1)
at C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:65:1
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:71:10)
at Module._compile (internal/modules/cjs/loader.js:701:30)
package.json
{
"name": "klay-dapp-boilerplate",
"version": "0.0.1",
"description": "boilerplate for klaytn-based app",
"main": "truffle.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server"
},
"dependencies": {
"caver-js": "^0.0.2-m",
"connect-privkey-to-provider": "^0.0.3",
"spin.js": "^4.0.0"
},
"devDependencies": {
"copy-webpack-plugin": "^4.6.0",
"eslint": "^4.19.1",
"webpack": "^4.7.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.4"
},
"eslintConfig": {
"env": {
"browser": true,
"node": true
}
}
}
truffle.js
// truffle.js config for klaytn.
const PrivateKeyConnector = require('connect-privkey-to-provider')
const NETWORK_ID = '1001'
const GASLIMIT = '20000000'
const URL ='https://api.baobab.klaytn.net:8651'
const PRIVATE_KEY = '0x80ea7e298ba2cbf484e6c0c0703ccf2ea94be7f8a1a097fc013042b4888a2e80'
module.exports = {
networks: {
klaytn: {
provider: new PrivateKeyConnector(PRIVATE_KEY, URL),
network_id: NETWORK_ID,
gas: GASLIMIT,
gasPrice: null,
}
}
}
Error
Your code works fine in my environment. Try to do these:
Remove node_modules
Remove package-lock.json
Update truffle package npm update -g truffle
Reinstall, using command npm i
After that just change solidity version in contracts folder
pragma solidity ^0.5.0;
In my case for changing some dependencies, I was deleting node_modules, but I had to erase package-lock.json too.
I closed all windows, deleted node_modules folder and package-lock.json and reinstalled it all again with npm install.

{Help }New: Setting Up

I am trying to install and do the Hello World sample from Facebook.
I have 2 problems:
When I run: create-react-native-app AwesomeProject I get this error, What does this mean:
You are currently running Node v4.4.2 but create-react-native-app
requires >=6. Please use a supported version of Node.
My package.json: { "name": "AwesomeProject", "version": "0.1.0", "private": true, "scripts": { "test": "make test", "start": "node index.js" }, "devDependencies": { "react-native-scripts": "1.5.0" } }
When I npm start I get this error:
SyntaxError: Unexpected reserved word 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
Function.Module.runMain (module.js:441:10) at startup (node.js:139:18)
at node.js:968:3
This is the code I copy and paste from Facebook Hello World sample.
Currently, you have'not clone AwesomeProject successful yet. You got the above error because you had older version of NodeJS (v4.4.2). Please follow step by step on below guidance:
Firstly, you need to install new one with version larger than 6.x.x (check and download it on the offical site).
Then, run create-react-native-app AwesomeProject again and make sure it is done with succesful message
Finally, run react-native start to launch the app.
Cheer!

How do I specify the path from which my Sublime Text Build will run?

I am trying to run mocha tests from my Sublime Text 3 build module. My mocha build is:
/* Mocha.sublime-build */
{
"shell_cmd": "mocha -c --opts test/mocha.opts $file",
"shell": true,
"working_dir": "${project_path}",
"target": "ansi_color_build",
"syntax": "Packages/ANSIescape/ANSI.tmLanguage"
}
When I use Cmd+B to run my mocha build it responds with an error because my Node version doesn't support "import" statements. I have a mocha.opts file:
--require babel-register
--recursive
When running Mocha from the command line in the root project directory it works fine. How do I get the Mocha Build system to run from the root directory and receive instructions from mocha.opts?
This is the error that gets reported. It doesnt appear to be running babel.
(function (exports, require, module, __filename, __dirname) { import { expect } from 'chai'
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:220:27
Here is what is in my .babelrc:
{
"presets": ["stage-0", "es2015"]
}
My file structure is:
/Project
->public
->tests
->mocha.opts
->fooTests
->individualFooTest.js