Cannot start a new React Native CLI project in WebStorm - react-native
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.
Related
React-native-windows installation
I tried to install react-native-windows. I have some troubleshoot with the command: npx react-native-windows-init --overwrite NoLatestReactNativeWindows: Error: No version of react-native-windows#latest found at getLatestRNWVersion (C:\Users\XXXX\AppData Local\npm-cache_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:249:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Object.reactNativeWindowsInit (C:\Users\XXXX\AppData\Local\npm-cache_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:533:36) { type: 'NoLatestReactNativeWindows', data: undefined } Command failed. Re-run the command with --verbose for more information.
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'. ??
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!"); };
How do I use Vite and Jest with IntelliJ?
I am trying to run a Jest integration test from Intellij. I right click and say run it tries to run but then I get... /bin/sh: vite: command not found I tried adding this to the env vars in the Intellij Run Dialog.... PATH=$PATH:/my/dir/node_modules/.bin But then I get... env: node: No such file or directory node:events:371 throw er; // Unhandled 'error' event ^ Error: spawn pgrep ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -2, code: 'ENOENT', syscall: 'spawn pgrep', path: 'pgrep', spawnargs: [ '-P', 6190 ] } I can confirm that vite is in /my/dir/node_modules/.bin and npx vite works from terminal. Vite is not (nor will I) installed globally
In my case I was using Puppeteer to run integration tests in the browser. Adding npm here... module.exports = { ... server: { command: `npx vite --port 8080 --mode ${process.env.ENV_MODE || "development"}`, port: 8080, launchTimeout: 10000, }, }; Notice was vite --port 8080 now npx vite --port 8080 This may not work with some older versions of NPM that don't include npx (don't remember version but think it is behind LTS).
'Module build failed: Error: Couldn't find preset "es2015" relative to directory' from newly created gatsby project
I have created a project following these steps: npm install -g gatsby gatsby new dev-blog cd dev-blog npm install Then I try to start by project by gatsby develop --host localhost --port 9000 At this point it throws an exception: Failed to require /Users/antkong/wd/blogs/gatsby/dev-blog/html.js ./html.js Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/antkong/wd" How can I fix this problem? Edit OS: OSX 10.12.4 Darwin mymac.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64 npm: 3.10.10 node: 6.10.2 Full stacktrace: ❯❯ npm run develop > gatsby-starter-default#1.0.0 develop /Users/antkong/wd/blogs/gatsby/dev-blog > gatsby develop Failed to require /Users/antkong/wd/blogs/gatsby/dev-blog/html.js ./html.js Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/antkong/wd" at /Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at File.initOptions (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/index.js:212:65) at new File (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/index.js:135:24) at Pipeline.transform (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/pipeline.js:46:16) at transpile (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/index.js:46:20) at /Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/fs-cache.js:79:18 at ReadFileContext.callback (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/fs-cache.js:15:14) at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:366:13) # (webpack)-require/lib/webpackRequireEntrypoint.js 1:20-41 I am also using nvm ❯❯ nvm list -> v6.10.2 system default -> v6 (-> v6.10.2) node -> stable (-> v6.10.2) (default) stable -> 6.10 (-> v6.10.2) (default) iojs -> N/A (default) lts/* -> lts/boron (-> v6.10.2) lts/argon -> v4.8.2 (-> N/A) lts/boron -> v6.10.2
gabsty new does not create a .babelrc that is needed by babel. The error is caused by the missing .babelrc. Here is the content of my .babelrc: { "presets": ["react", "es2015", "stage-0"], "env": { "development": { "presets": ["react-hmre"] } } }