I've encountered the following error while using eslint command in my project:
$ eslint ./src/ --max-warnings 69 --ext .js,.jsx,.ts,.tsx
Oops! Something went wrong! :(
ESLint: 7.7.0
.../node_modules/language-tags/lib/Tag.js:17
static ERR_DEPRECATED = 1;
^
SyntaxError: Unexpected token =
at new Script (vm.js:83:7)
at NativeCompileCache._moduleCompile (.../node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (.../node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (.../node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (.../node_modules/language-tags/lib/index.js:11:11)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I am using the following plugins and configs for eslint:
{
"#typescript-eslint/eslint-plugin": "4.15.2",
"#typescript-eslint/parser": "4.15.2",
"eslint": "7.7.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-airbnb-typescript": "9.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-dirnames": "1.0.3",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "5.0.3",
"eslint-plugin-unicorn": "18.0.1"
}
I've tried to reproduce the correct package configuration which worked fine before I started switching my project from npm to yarn v1 (this problem happened because of that). But current yarn.lock is about 25000 lines long and it is tough to compare it to package-lock.json.
I solved this problem by myself eventually and want to share the solution.
The problem lied in the eslint-plugin-jsx-a11y#6.4.1 package.
Its dependencies are listed below:
dependencies:
"#babel/runtime" "^7.11.2"
aria-query "^4.2.2"
array-includes "^3.1.1"
ast-types-flow "^0.0.7"
axe-core "^4.0.2"
axobject-query "^2.2.0"
damerau-levenshtein "^1.0.6"
emoji-regex "^9.0.0"
has "^1.0.3"
jsx-ast-utils "^3.1.0"
language-tags "^1.0.5"
As it turns out, yarn v1 resolved the dependency language-tags#^1.0.5 as language-tags#1.0.7 which caused the eslint command to stop working altogether.
language-tags#^1.0.5:
version "1.0.7"
resolved ".../npm/language-tags/-/language-tags-1.0.7.tgz#41cc248730f3f12a452c2e2efe32bc0bbce67967"
integrity ...
dependencies:
language-subtag-registry "^0.3.20"
So the solution is to either change the version of language-tags in your lock file from 1.0.7 to 1.0.5 or provide a yarn resolution where you would specify the desired package version
"resolutions": {
"language-tags": "1.0.5"
}
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!");
};
FAIL tests/App-test.js
● Test suite failed to run
/Users/runner/runners/2.168.2/work/1/s/node_modules/#react-navigation/stack/lib/commonjs/views/assets/back-icon.png:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){�PNG
SyntaxError: Invalid or unexpected token
at ScriptTransformer._transformAndBuildScript (node_modules/#jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (node_modules/#jest/transform/build/ScriptTransformer.js:579:25)
at Object.<anonymous> (node_modules/#react-navigation/stack/lib/commonjs/index.tsx:13:3)
Here's the solution that worked for me:
You have to do install npm install --save-dev identity-obj-proxy (or yarn add identity-obj-proxy) to get the necessary dependencies.
"jest": {
"moduleNameMapper": {
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy"
}
}
Source: https://github.com/facebook/jest/issues/2663#issuecomment-341384494
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.
I'm trying out webpack for the first time, but I cant even get past the installation of webpack-cli
I get this error
{ Error: Cannot find module 'webpack-cli'
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 runCommand.then (C:\Users\Henrik\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:142:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
When I run webpack it suggest to auto install it, but fails at that.
Any suggestions?
-- EDIT 1 --
My package.json looks like this:
{
"name": "webpacktest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {}
}
I've tried running this : "npm install webpack-cli --save-dev" amongst various other suggestions found all over the web
Try this:
npm install -g --save-dev webpack-cli
Looks like you might be trying to use a global webpack package with a local webpack-cli package.
Try adding webpack to your devDependencies and running webpack from inside an npm/yarn script, and if that doesn't work try uninstalling your global webpack binary.
I executed your package.json and it worked without any errors
Try deleting the node_modules folder and run the comand npm install from the prompt