Could not resolve esbuild entry points - esbuild

The following esbuild CLI command works:
esbuild server/**/* --platform=node --tsconfig=tsconfig.server.json --outdir=dist
But if I create a config file and execute it with node esbuild.js command, it's not working. The error says that it could not resolve server/**/*.
esbuild.js
esbuild.build({
entryPoints: ['server/**/*'],
platform: 'node',
tsconfig: 'tsconfig.server.json',
outdir: 'dist'
}).catch({
process.exit(1);
})
I don't understand why it isn't working like the CLI command does.

Your shell is the thing that expands the server/**/* syntax before the command-line arguments are passed to the esbuild command. Expanding globs is not a feature of esbuild itself. If you need to perform this expansion in JavaScript you'll need to use a library such as https://github.com/isaacs/node-glob#globsyncpattern-options.

Related

Ubuntu in Windows (WSL2) Adding C: in front of /mnt/c/ path?

I just installed WSL2 and Ubuntu as one of my terminal options in Windows Terminal, as I want to now do my JavaScript development in Windows instead of Mac (our clients are all Windows users).
When I try to build my Node package with "npm run build", which is just a script of "babel lib -d dist", I receive the following error, which suggests to me either Windows, the WSL2, or something in my environment variables is pushing a "C:" in front of "\mnt\c", generating the following error:
internal/modules/cjs/loader.js:883
throw err;
^
**Error: Cannot find module 'C:\mnt\c\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'**
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
And here is my PATH with 'printenv' in Ubuntu:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files/VanDyke Software/Clients/:/mnt/c/Program Files (x86)/Razer Chroma SDK/bin:/mnt/c/Program Files/Razer Chroma SDK/bin:/mnt/c/Program Files (x86)/Razer/ChromaBroadcast/bin:/mnt/c/Program Files/Razer/ChromaBroadcast/bin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Windows/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/csomm/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Git/mingw64/bin:/mnt/c/Program Files/Git/usr/bin:/mnt/c/Program Files (x86)/QuickTime/QTSystem/:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/csomm/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/csomm/AppData/Local/atom/bin:/mnt/c/Users/csomm/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/JetBrains/WebStorm 2021.3.1/bin:/mnt/c/Users/csomm/AppData/Local/Programs/Hyper/resources/bin:/snap/bin
Any thoughts/ideas?
This has been resolved. The problem was that I had installed NVM/NPM first in Command Prompt, and owing to Windows WSL2 cross-utilizing Linux and Windows applications, NVM that was installed in Windows would run in my Ubuntu just fine, but the NPM would fail owing to relative path issue.
Solution was to "re-install" NPM natively within Ubuntu. Now it works perfectly.

SyntaxError: Cannot use import statement outside a module when run gulp server / gulp watch in my ruby project

On my ruby project when I try to run gulp (gulp server, gulp watch) I have the following error :
Users/workspace/website2019/gulpfile.babel.js:1
import del from 'del';
^^^^^^
SyntaxError: Cannot use import statement outside a module
I don't get how can I fix it, if someone could help me please,
you use babel transpilation with gulp because of the file gulpfile.babel.js For this reason you need to install babel. according to the documentation you need #babel/register and #babel/preset-env for transpiling your import syntax.
So run the following command in your project folder
npm install --save-dev #babel/core #babel/register
Afterwards create the babel configuration file .babelrc in the root folder and add the following lines to it
{
"presets": [
[
"#babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
make sure you have this line in package.json
"type": "module"

Electron fix "ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command"

I recently stepped down my electron application removed knex and sqlite since it was painfully complicated to creating a rebuild on windows also when i made an executable for windows sqlite database didn't seem to work. Linux executable worked fine with sqlite guessing the same with mac.
To use sqlite i had rebuilt the application using electron-rebuild. In order to clear the rebuild i did rm -rf node_modules && npm install
I have eventually decided to use IndexDB using dexie.
However now when i try to run my program from npm i get
ERROR:buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
How do i fix this, why is it happening ?
NB: The application works just fine but this error i the terminal is just annoying and i have no idea why its happenning
Do a test,
electron /path/to/the/app [You will get that Error]
Try
electron --disable-gpu /path/to/the/app [You mayn't get that Error]
The fix was to add "--disable-gpu" to the command-line to force the
web view not to use gpu features. I was able to accomplish this in an
electron app by editing the package.json file in app root and changing
the line like "start": "electron ." to "start": "electron .
--disable-gpu"
Refer https://github.com/electron/electron/issues/7834#issuecomment-275802528
Based on Sudhakar RS answer , I made a script in my package.json to not use GL
here is my package.json
{
...
"scripts": {
"start": "electron --disable-gpu .", // --disable GL ERROR and use CPU
...
}
...
}
Then in your terminal run
npm run start
I had the same error running electron-quick-start but not when running electron-boilerplate.
Investigating the error I found this question and for me also, starting with "electron --disable-gpu ." prevents the error message. But I didn't have to do that with electron-boilerplate. So, comparing the two I traced the difference to the inclusion of electron-debug in electron-boilerplate and, ultimately, to this: process.stderr.fd.
Thus far, the minimal change I have found sufficient to avoid the error is:
diff --git a/main.js b/main.js
index 3508c8e..7df262b 100644
--- a/main.js
+++ b/main.js
## -2,6 +2,8 ##
const {app, BrowserWindow} = require('electron')
const path = require('path')
+process.stderr.fd;
+
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
So, now I am trying to understand what process.stderr.fd; does and how it prevents the error message from appearing. It seems odd that merely getting the file descriptor of stderr would prevent the error but evidently it does.
I am also curious about the relative merits of disabling the GPU Vs getting the file descriptor.
edit: it is sufficient to get the stream with process.stderr; it is not necessary to get the file descriptor.
My solution for issue:
"dev": ".electron-vue/dev-runner.js --disable-gpu"

Running Ant build from Gradle, how to pass -lib argument?

I want to slowly migrate to a better build and dependency resolution process, we are currently using Ant with local file dependencies.
We chose to migrate to gradle ,so as a first step I would like to simply run my current ant build from a gradle sript. But i dont know how to pass the -lib classpath to ant. Im getting errors of missing dependencies.
This is my gradle.build:
apply plugin: 'java'
task someProperties {
ext.LIBS_CATW = "backend/java-src/lib"
ext.LIB_SERVLET = "/usr/local/apache-tomcat-7.0.32/lib/servlet-api.jar"
}
dependencies {
compile files('/usr/local/apache-tomcat-7.0.32/lib/servlet-api.jar')
compile fileTree(dir: 'backend/java-src/lib', include: '*.jar')
}
I use this shell script to run ant from command line.
#!/bin/bash
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"
ROOT_DIR="/Users/poolebu/catwizardMultitenant/catwizard/catwBackend/branches/branchSpringSecurity/"
DIR_MT="$ROOT_DIR"
LIBS_CATW="$ROOT_DIR/backend/java-src/lib"
LIB_SERVLET="/usr/local/apache-tomcat-7.0.32/lib/servlet-api.jar"
ANT_TARGET="allButFlex"
cd $DIR_MT
ant -lib $LIBS_CATW -lib $LIB_SERVLET $ANT_TARGET
This is one of the many dependency errors I´m getting
[ant:javac] /Users/poolebu/catwizardMultitenant/catwizard/catwBackend/branches/branchSpringSecurity/backend/java-src/catw-common/src/com/bamboo/common/factory/SpringFactory.java:5: error: package flex.messaging does not exist
[ant:javac] import flex.messaging.FlexFactory;
[ant:javac] ^

Not a valid Windows application error in PHPStorm file watcher

Here's what I get in my CMD:
C:\Documents and Settings\Administrator>lessc
lessc: no input files
... (long program output)
C:\Documents and Settings\Administrator>"C:\Documents and Settings\Administrator
\Dane aplikacji\npm\lessc"
lessc: no input files
usage: lessc [option option=parameter ...] <source> [destination]
... (long program output)
C:\Documents and Settings\Administrator>
But when I add a file watcher in my PHPStorm for LESS and specify the program to:
C:\Documents and Settings\Administrator\Dane aplikacji\npm\lessc, I get the following error:
16:52:38 An exception occurred while executing watcher 'LESS'. Watcher has been disabled. Fix it.: Cannot run program "C:\Documents and Settings\Administrator\Dane aplikacji\npm\lessc" (in directory "C:\Documents and Settings\Administrator\Pulpit\bootstrap\css"): CreateProcess error=193, %1 nie jest prawid³ow¹ aplikacj¹ systemu Wi
Why is this happening and how can I fix this?
You seems to forgot how Windows/DOS works ;)
When you trying to execute lessc in Command Shell, Windows will search for such file. If nothing found -- it will search for lessc.exe, lessc.com, lessc.bat, lessc.cmd and so on -- depends on value of PATHEXT environment variable. Just type SET in command prompt and see for yourself.
In PhpStorm (or any other software) where NO command shell is used but command executed DIRECTLY, you have to specify FULL program name, which is lessc.cmd

Resources