AWS Amplify: How to install sharp in Lambda Trigger? - amazon-s3

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!");
};

Related

Why npx cdk deploy is using a windows path instead of linux path in WSL:Ubuntu

When I do npx cdk deploy in WSL:Ubuntu it fails, I noticed, in the error message, that the following Windows path is used:
'C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\#aws-cdk\aws-lambda-python-alpha\lib'
chazz#5CG1363M2J:/mnt/c/users/chz11/projects/lambdaWithDependencies/infra$ npx cdk deploy
Error: spawnSync docker ENOENT
at Object.spawnSync (node:internal/child_process:1110:20)
at Object.spawnSync (node:child_process:857:24)
at dockerExec (C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\aws-cdk-lib\core\lib\bundling.js:1:4953)
at Function.fromBuild (C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\aws-cdk-lib\core\lib\bundling.js:1:3578)
at new Bundling (C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\#aws-cdk\aws-lambda-python-alpha\lib\bundling.ts:84:39)
at Function.bundle (C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\#aws-cdk\aws-lambda-python-alpha\lib\bundling.ts:55:44)
at new PythonFunction (C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\#aws-cdk\aws-lambda-python-alpha\lib\function.ts:76:22)
at new InfraStack (C:\users\chz11\projects\lambdaWithDependencies\infra\lib\infra-stack.ts:14:10)
at Object.<anonymous> (C:\users\chz11\projects\lambdaWithDependencies\infra\bin\infra.ts:6:1)
at Module._compile (node:internal/modules/cjs/loader:1149:14) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawnSync docker',
path: 'docker',
spawnargs: [
'build',
'-t',
'cdk-57e0e869155529ae0e4e318293a690729e2291cb95884c59fe2cf7aa7a9e19bd',
'--platform',
'linux/amd64',
'--build-arg',
'IMAGE=public.ecr.aws/sam/build-python3.9',
'C:\\users\\chz11\\projects\\lambdaWithDependencies\\infra\\node_modules\\#aws-cdk\\aws-lambda-python-alpha\\lib'
]
}
How can I make it use a Linux path and not 'C:\users\chz11\projects\lambdaWithDependencies\infra\node_modules\#aws-cdk\aws-lambda-python-alpha\lib'. ??

Gets ENOTDIR error when yarn start for expo project

I activated yarn by following yarn official docs (https://yarnpkg.com/getting-started/install)
I created an expo app with yarn by following react native official docs (https://reactnative.dev/docs/environment-setup)
But when I run yarn start I get below error
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error: spawn ENOTDIR
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:700:9)
at spawn (/Users/minseok/Repository/test/.yarn/cache/cross-spawn-npm-6.0.5-2deab6c280-f893bb0d96.zip/node_modules/cross-spawn/index.js:12:24)
at run (/Users/minseok/Repository/test/.yarn/unplugged/expo-npm-46.0.10-310b54dc3f/node_modules/expo/bin/cli.js:11:12)
at Object.<anonymous> (/Users/minseok/Repository/test/.yarn/unplugged/expo-npm-46.0.10-310b54dc3f/node_modules/expo/bin/cli.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require$$0.Module._extensions..js (/Users/minseok/Repository/test/.pnp.cjs:20807:33)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.require$$0.Module._load (/Users/minseok/Repository/test/.pnp.cjs:20630:22) {
errno: -20,
code: 'ENOTDIR',
syscall: 'spawn'
}
How can I fix this?

Failed to install reactide " Error: Cannot find module 'vs/editor/contrib/gotoSymbol/goToCommands' "

I try to install reactide on Windows 10. After cloning its git repository and installing dependencies. When I run the command npm run webpack-production I get the following errors:
C:\reactide(3.0-release -> origin) (reactide#3.0.0)
λ npm run webpack-production
> reactide#3.0.0 webpack-production
> webpack --mode production
C:\reactide\node_modules\webpack-cli\bin\cli.js:281
throw err;
^
Error: Cannot find module 'vs/editor/contrib/gotoSymbol/goToCommands'
Require stack:
- C:\reactide\node_modules\monaco-editor-webpack-plugin\out\index.js
- C:\reactide\webpack.config.js
- C:\reactide\node_modules\webpack-cli\bin\utils\convert-argv.js
- C:\reactide\node_modules\webpack-cli\bin\cli.js
- C:\reactide\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.resolve (C:\reactide\node_modules\v8-compile-cache\v8-compile-cache.js:164:23)
at resolveMonacoPath (C:\reactide\node_modules\monaco-editor-webpack-plugin\out\index.js:34:28)
at C:\reactide\node_modules\monaco-editor-webpack-plugin\out\index.js:173:63
at Array.map (<anonymous>)
at createLoaderRules (C:\reactide\node_modules\monaco-editor-webpack-plugin\out\index.js:173:43)
at MonacoEditorWebpackPlugin.apply (C:\reactide\node_modules\monaco-editor-webpack-plugin\out\index.
at webpack (C:\reactide\node_modules\webpack\lib\webpack.js:51:13)
at processOptions (C:\reactide\node_modules\webpack-cli\bin\cli.js:272:16)
at C:\reactide\node_modules\webpack-cli\bin\cli.js:364:3
at Object.parse (C:\reactide\node_modules\yargs\yargs.js:576:18)
at C:\reactide\node_modules\webpack-cli\bin\cli.js:49:8
at Object.<anonymous> (C:\reactide\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\reactide\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\reactide\\node_modules\\monaco-editor-webpack-plugin\\out\\index.js',
'C:\\reactide\\webpack.config.js',
'C:\\reactide\\node_modules\\webpack-cli\\bin\\utils\\convert-argv.js',
'C:\\reactide\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\reactide\\node_modules\\webpack\\bin\\webpack.js'
]
}
npm ERR! code 1
npm ERR! path C:\reactide
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "webpack --mode production"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2022-07-08T13_47_50_402Z-debug.log
I tried looking for the solution on this GitHub page and this stack overflow question but no success. I have installed all the dependencies.
The error occurs in monaco-editor-webpack-plugin used in webpack.config.js:
plugins: [
new MonacoWebpackPlugin(),
],
I found this issue in official repo with a similar error and I fixed the problem like this:
plugins: [
new MonacoWebpackPlugin({
features: ["!gotoSymbol"],
languages: ["!abap"],
}),
],

Cannot start a new React Native CLI project in WebStorm

The react-native-cli is generating the project fine when I use this command in terminal:
react-native init myapp
But for some reason WebStorm cannot create new React Native project. When I try I get this error:
/home/sagar/.nvm/versions/node/v8.9.1/bin/node
/home/sagar/.nvm/versions/node/v8.9.1/lib/node_modules/react-native-cli/index.js init bookip
/bin/sh: 1: npm: not found
This will walk you through creating a new React Native project in /tmp/1512313270685-0/bookip
Installing react-native...
Consider installing yarn to make this faster: https://yarnpkg.com
{ Error: Command failed: npm install --save --save-exact react-native
at checkExecSyncError (child_process.js:601:13)
at execSync (child_process.js:641:13)
at run (/home/sagar/.nvm/versions/node/v8.9.1/lib/node_modules/react-native-cli/index.js:294:5)
at createProject (/home/sagar/.nvm/versions/node/v8.9.1/lib/node_modules/react-native-cli/index.js:249:3)
at init (/home/sagar/.nvm/versions/node/v8.9.1/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/home/sagar/.nvm/versions/node/v8.9.1/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
error: null,
cmd: 'npm install --save --save-exact react-native',
file: '/bin/sh',
args:
[ '/bin/sh',
'-c',
'npm install --save --save-exact react-native' ],
options:
{ stdio: [ [Object], [Object], [Object] ],
shell: true,
file: '/bin/sh',
args:
[ '/bin/sh',
'-c',
'npm install --save --save-exact react-native' ],
envPairs:
[ 'PATH=/home/sagar/bin:/home/sagar/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin',
'LC_MEASUREMENT=ne_NP',
'XAUTHORITY=/home/sagar/.Xauthority',
'XMODIFIERS=#im=ibus',
'LC_TELEPHONE=ne_NP',
'XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop',
'GDMSESSION=ubuntu',
'MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path',
'LC_TIME=ne_NP',
'GTK_IM_MODULE=ibus',
'DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Sq2eReOVZr',
'DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path',
'XDG_CURRENT_DESKTOP=Unity',
'LD_LIBRARY_PATH=/home/sagar/apps/WebStorm-172.3757.55/bin:',
'UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1240',
'QT4_IM_MODULE=xim',
'LC_PAPER=ne_NP',
'QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1',
'LOGNAME=sagar',
'JOB=unity-settings-daemon',
'PWD=/tmp/1512313270685-0',
'IM_CONFIG_PHASE=1',
'LANGUAGE=en_US',
'SHELL=/bin/bash',
'LC_ADDRESS=ne_NP',
'GIO_LAUNCHED_DESKTOP_FILE=/home/sagar/.local/share/applications/jetbrains-webstorm.desktop',
'GTK2_MODULES=overlay-scrollbar',
'INSTANCE=',
'OLDPWD=/home/sagar/apps/WebStorm-172.3757.55/bin',
'GNOME_DESKTOP_SESSION_ID=this-is-deprecated',
'UPSTART_INSTANCE=',
'GTK_MODULES=gail:atk-bridge:unity-gtk-module',
'CLUTTER_IM_MODULE=xim',
'XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0',
'COMPIZ_BIN_PATH=/usr/bin/',
'SESSIONTYPE=gnome-session',
'XDG_SESSION_DESKTOP=ubuntu',
'SHLVL=0',
'LC_IDENTIFICATION=ne_NP',
'LC_MONETARY=ne_NP',
'COMPIZ_CONFIG_PROFILE=ubuntu',
'QT_IM_MODULE=ibus',
'UPSTART_JOB=unity7',
'JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64',
'XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg',
'LANG=en_US.UTF-8',
'GNOME_KEYRING_CONTROL=',
'XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0',
'XDG_SESSION_ID=c2',
'XDG_SESSION_TYPE=x11',
'DISPLAY=:0',
'LC_NAME=ne_NP',
'GDM_LANG=en_US',
'XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/sagar',
'UPSTART_EVENTS=xsession started',
'GPG_AGENT_INFO=/home/sagar/.gnupg/S.gpg-agent:0:1',
'DESKTOP_SESSION=ubuntu',
'SESSION=ubuntu',
'USER=sagar',
'XDG_MENU_PREFIX=gnome-',
'GIO_LAUNCHED_DESKTOP_FILE_PID=20103',
'QT_ACCESSIBILITY=1',
'LC_NUMERIC=ne_NP',
'SSH_AUTH_SOCK=/run/user/1000/keyring/ssh',
'XDG_SEAT=seat0',
'QT_QPA_PLATFORMTHEME=appmenu-qt5',
'XDG_VTNR=7',
'XDG_RUNTIME_DIR=/run/user/1000',
'HOME=/home/sagar',
'GNOME_KEYRING_PID=' ],
killSignal: undefined },
envPairs:
[ 'PATH=/home/sagar/bin:/home/sagar/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin',
'LC_MEASUREMENT=ne_NP',
'XAUTHORITY=/home/sagar/.Xauthority',
'XMODIFIERS=#im=ibus',
'LC_TELEPHONE=ne_NP',
'XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/snapd/desktop',
'GDMSESSION=ubuntu',
'MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path',
'LC_TIME=ne_NP',
'GTK_IM_MODULE=ibus',
'DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Sq2eReOVZr',
'DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path',
'XDG_CURRENT_DESKTOP=Unity',
'LD_LIBRARY_PATH=/home/sagar/apps/WebStorm-172.3757.55/bin:',
'UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1240',
'QT4_IM_MODULE=xim',
'LC_PAPER=ne_NP',
'QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1',
'LOGNAME=sagar',
'JOB=unity-settings-daemon',
'PWD=/tmp/1512313270685-0',
'IM_CONFIG_PHASE=1',
'LANGUAGE=en_US',
'SHELL=/bin/bash',
'LC_ADDRESS=ne_NP',
'GIO_LAUNCHED_DESKTOP_FILE=/home/sagar/.local/share/applications/jetbrains-webstorm.desktop',
'GTK2_MODULES=overlay-scrollbar',
'INSTANCE=',
'OLDPWD=/home/sagar/apps/WebStorm-172.3757.55/bin',
'GNOME_DESKTOP_SESSION_ID=this-is-deprecated',
'UPSTART_INSTANCE=',
'GTK_MODULES=gail:atk-bridge:unity-gtk-module',
'CLUTTER_IM_MODULE=xim',
'XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0',
'COMPIZ_BIN_PATH=/usr/bin/',
'SESSIONTYPE=gnome-session',
'XDG_SESSION_DESKTOP=ubuntu',
'SHLVL=0',
'LC_IDENTIFICATION=ne_NP',
'LC_MONETARY=ne_NP',
'COMPIZ_CONFIG_PROFILE=ubuntu',
'QT_IM_MODULE=ibus',
'UPSTART_JOB=unity7',
'JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64',
'XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg',
'LANG=en_US.UTF-8',
'GNOME_KEYRING_CONTROL=',
'XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0',
'XDG_SESSION_ID=c2',
'XDG_SESSION_TYPE=x11',
'DISPLAY=:0',
'LC_NAME=ne_NP',
'GDM_LANG=en_US',
'XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/sagar',
'UPSTART_EVENTS=xsession started',
'GPG_AGENT_INFO=/home/sagar/.gnupg/S.gpg-agent:0:1',
'DESKTOP_SESSION=ubuntu',
'SESSION=ubuntu',
'USER=sagar',
'XDG_MENU_PREFIX=gnome-',
'GIO_LAUNCHED_DESKTOP_FILE_PID=20103',
'QT_ACCESSIBILITY=1',
'LC_NUMERIC=ne_NP',
'SSH_AUTH_SOCK=/run/user/1000/keyring/ssh',
'XDG_SEAT=seat0',
'QT_QPA_PLATFORMTHEME=appmenu-qt5',
'XDG_VTNR=7',
'XDG_RUNTIME_DIR=/run/user/1000',
'HOME=/home/sagar',
'GNOME_KEYRING_PID=' ],
stderr: null,
stdout: null,
pid: 20527,
output: [ null, null, null ],
signal: null,
status: 127 }
Command `npm install --save --save-exact react-native` failed.
Done
It says npm not found when I know it is there.
I have Node 8.9.1 & npm 5.5.1
Looks like npm is not on your $PATH. Do you launch WebStorm from terminal, or from desktop/System menu? In the latter case, WebStorm only sees environment variables configured in .profile (login shell), but not in interactive shell configuration files (like ~/.bashrc). Plus, NVM alters interactive shell configuration files only during installation phase (https://github.com/creationix/nvm/blob/v0.28.0/install.sh#L126)
Possible workarounds:
Workaround 1: make required variables available in a login shell (i.e. for Bash, move them from .bashrc to .bash_profile or .profile).
Workaround 2: run IDE from a terminal
Workaround 3: edit WebStorm desktop launcher and set command to /bin/bash -l -i -c "/path/to/webstorm.sh" (for bash)
Try pointing to your usr/local/bin/node folder. These are my settings with WebStorm 2017.3 and it worked for me.
Consider installing yarn to make this faster: https://yarnpkg.com
After yarn was installed error is gone.

{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!