How do I use Vite and Jest with IntelliJ? - intellij-idea

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).

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'. ??

I have trouble with constructing a vue.js project by using npm or yarn

I have trouble with constructing a vue.js project by using npm or yarn.
the cmd: $ vue init webpack my-project
# Installing project dependencies ...
# ========================
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn C:\WINDOWS\system32\cmd.exe; ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn C:\\WINDOWS\\system32\\cmd.exe;',
path: 'C:\\WINDOWS\\system32\\cmd.exe;',
spawnargs: [ '-c', 'yarn install' ]
}
the picture

Running "vue ui" on Windows Subsystem For Linux (WSL) will not work

An error will get generated when running:
vue ui
vue ui
🚀 Starting GUI...
🌠 Ready on http://localhost:8001
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd.exe',
path: 'cmd.exe',
spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:8001' ]
}
Expected to get an app running on port localhost:8001, but the above error gets generated.
The reason is because it is trying to open a browser window from inside WSL terminal.
Instead, do the following:
vue ui --headless
This will avoid running the cmd.exe to open a browser and instead run the app on port 8001. You'll have to open a browser manually to http://localhost:8001

Why do I get this error trying to run this VUE JS repository?

This is a VUE JS MASONRY project on the GitHub. I just trying to run
it. I've already run the npm install before run it. It seems like the
all the packages have been installed properly.
PS C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master>npm start
> vue-masonry-demo#1.0.0 start C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master
> node build/dev-server.js
> Starting dev server...
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1300:14)
at listenInCluster (net.js:1348:12)
at Server.listen (net.js:1436:7)
at Function.listen (C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master\build\dev-server.js:83:18)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1327:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8080
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-masonry-demo#1.0.0 start: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-masonry-demo#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-05T22_23_37_278Z-debug.log
PS C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master>
PACKAGE.JSON
{ "name": "vue-masonry-demo", "version": "1.0.0",
"description": "A Vue.js project", "author": "Mikhail Kuznetcov
", "private": true, "scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js" },
Error: listen EADDRINUSE: address already in use :::8080
If you check it here, you will figure it out.

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.