We use grunt to build our HTML5 Applications on the SAP Hana Cloud Platform. Unfortunately it is very very slow and takes hours sometimes it runs in the 6 minutes timeout to build a small App.
The main reason is that everytime the necessary node packages are installed and npm install runs which takes hours :(
Has anyone experiences with this problem?
After creating some incidents the SAP Cloud Developers Team improve the performance and tell me not to use tilde character in package.json - this leads to many dependencies and maybe a timeout during npm install.
So a package.json should look like this when you are working with SAP Web IDE Full-Stack:
{
"name": "grunt-build",
"version": "0.0.1",
"description": "Grunt build",
"private": true,
"devDependencies": {
"grunt-stripcomments": "0.7.2",
"grunt-remove-logging-calls": "0.1.2",
"grunt-postcss": "0.9.0",
"autoprefixer": "7.2.4",
"grunt-contrib-less": "1.4.1",
"grunt-contrib-cssmin": "2.2.1",
"#sap/grunt-sapui5-bestpractice-build": "1.3.33"
}
}
Related
I followed various online steps in Github forums and blogs to install VcsXsrv so that I could run an electron app through WSL for development. But I have been stuck on the following error when running yarn start:
/home/me/dev/my-electron-app-2/node_modules/electron/dist/electron exited with signal SIGTRAP
Specs:
AMD Radeon R9 380 Series
Windows 10 Pro Build 19044.1826 (3/23/21)
VcsXsrv installed (1.20.14.0)
WSL2 (latest) for Ubuntu 18.04
Dev Setup:
Node 16.15.0
Npm 8.5.5
package.json
{
"name": "myapp",
"version": "1.0",
"description": "My Desktop App",
"main": "main.js",
"scripts": {
"start": "electron .",
},
"author": "Me",
"license": "Apache-2.0",
"dependencies": {
"compromise": "^13.11.1",
"compromise-numbers": "^1.3.0",
"compromise-sentences": "^0.3.0",
"electron": "^19.0.8"
},
"devDependencies": {
"electron-packager": "^15.2.0"
}
}
Steps Tried:
Updating from Electron 15 to 19
Clearing package-lock.json
Making sure VcsXsrv was not blocked by firewall (public/private)
Updating WSL from 1 to 2
What did it I think was following this tutorial, specifically installing those missing libraries: https://www.beekeeperstudio.io/blog/building-electron-windows-ubuntu-wsl2
Incomplete list of libraries needed for electron/WSL Xserver usage:
libnss3-dev
libgdk-pixbuf2.0-dev
libgtk-3-dev
libxss-dev
libasound2
libgconf-2-4
libatk1.0-0
Related questions that were useful:
General setup: How to set up working X11 forwarding on WSL2
Similar fault: Electron not starting properly due to SIGTRAP
Another similar fault: Electron in Docker: SIGTRAP, ELIFECYCLE, errno1
WSL issue: https://github.com/microsoft/WSL/issues/6430
Another setup guide: https://gist.github.com/caseywatts/9700b402b6b51d1d6af9f0b206739770
I am building a server and a client nwjs app, but I can't open both at the same time. I wonder if there is any way to do this. I run npm run dev on both of my opened VS Code but when I run this command on the second app it just won't open at all (doesn't matter which one is the second app I would like to run). I tried to build the client app and run it and after it run the server app but it's the same, the second app won't start.
This is my package.json file in both app, I don't know if this helps at all. Only the name is different in the apps (nwjs_client and nwjs_server)
{
"name": "nwjs_server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nw src/",
"prod": "nwbuild --platforms win32,win64,osx64,linux32,linux64 --buildDir dist/ src/"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"nw": "^0.49.1"
}
}
I'm willing to accept any answers, I don't know if it is even possible to run 2 different nwjs apps.
I'm confused by what you are trying to do.
If you are trying to run an NW.js that, instead of loading directly from a index.html, it loads displays a page from a local webserver:
Create an server.js that spins up a local web server on a specific port (like 4263 or something not super common).
If you need any node_modules for this (like express) make sure it is a dependency and not a devDependency.
Set your "main" in the package.json to "http://localhost:4263 using the same port as the server
set your "node-main" to "server.js", this will run in the node context before your window is displayed when starting the app.
Set your "node-remote" to "http://localhost:4263" using the same port also. This will allow Node commands to run on that URL when loaded in NW.js.
If you are wanting to run two commands at the same time you can:
npm install --save-dev concurrently wait-on. This will install two devDeps
Set your npm script to "start": "concurrently \"npm run serve\" \"wait-on http://localhost:4263 && nw .\""
This will run your npm run serve command, which presumably spins up a local webserver for development, if using something like webpack, this could take a minute. Then it waits until localhost:4263 actually returns a response. Then it launches NW.js
concurrently will also let you run any two (or more) commands at the same time.
I am trying to optimize my CI build step. I want to install certain dependencies before installing others. How can I achieve that?
For example, suppose my package.json file is:
{
"name": "my-project",
"version": "1.0.0",
"author": "krismath",
"dependencies": {
"lib-a": "^1.5.13",
"lib-b": "^0.7.2",
"lib-c": "^15.0.61"
}
I want to install lib-b first in order to use it in other build steps. If I do
npm install lib-b
this doesn't guarantee that the version of lib-b will be semantically compatible with the one in package.json.
This is definitely a theoretical question, but why does running npm init ask a bunch of questions for setting up the fields below?
"name": "my-project-that's-definitely not going to npm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
A very large percentage of us are using npm just for the package management aspect of it. It seems to me like there should be an option to not set it up as anything BUT a package manager, so just:
"dependencies": {
"#whatever/somepackage": ">=4.0.0-beta <5.0.0",
},
The only justification I can think of is that a lot of people also use npm as a build tool, so this provides an entry point for running scripts. Is that correct? Are there other reasons?
P.S. I know I can use -y flag to default the fields, but that still creates them.
You are correct that npm foremost purpose is a package manager.
And being a package manager, it manages various aspect of a package.
Being a package, it means your code should be able to distribute and reuse by others.
Thus that's why basic information such as name, version, and license are needed.
And npm init is the best place and best time to declare those.
As you mention, you can use npm init -y to use default values so that you don't have to answer them.
My remote debugging (Via Chrome with React-native dev tools 0.14.8) used to work fine.
I am not sure what exactly happened in between (I upgraded to react-native 0.21, did an update to android studio, updated Linux Mint 17.3 with apt-get update/ upgrade).
But now all I see is
"Please Wait
Connecting to Remote debugger" for about 5-8 seconds on my emulator, and then I get the error (see attached image):
"Unable to connect with remote debugger"
I have tried re-installing Chrome React-native extensions. Tried rebuilding my app. Did not help.
I am not exactly sure where the problem is. May be I just need to increase a value for connection timeout.. but there does not seem to be an option like that.
Below is also my package.json (it took a couple of days to go through the 0.20 to 0.21 upgrade, due to various dependency problems).
May be there is a new settings there that I am missing, that somebody could point out.
{
"name": "ftesting",
"version": "1.0.0",
"description": "ftesting desc",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node_modules/react-native/packager/packager.sh",
"android-setup-port": "adb reverse tcp:8081 tcp:8080",
"test": "eslint ./src/js.app/my.forms",
"start": "rnws start",
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc"
},
"repository": {
"type": "git",
"url": "xyz" },
"keywords": [
"ftesting"
],
"author": "ls",
"license": "MIT",
"engines": {
"node": ">=4",
"npm": ">=2 <4"
},
"devDependencies": {
"babel-eslint": "^6.0.0-beta.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"eslint": "~2.2.0",
"eslint-loader": "^1.1.1",
"eslint-plugin-react": "^4.2.0"
},
"dependencies": {
"react-native": "^0.21.0",
"#remobile/react-native-splashscreen": "^1.0.3",
"react-native-blur": "^0.7.10",
"react-native-htmlview": "^0.2.0",
"react-native-material-kit": "^0.3.0",
"react-native-material-design": "^0.3.3"
}
}
There's a github issue posted with this problem. You can follow there:
https://github.com/facebook/react-native/issues/6390
Maybe it's silly problem for someone else, if it helps, for me the problem solved when I connected the wifi (I had disconnected it :)
I realized it was a connectivity problem, when I've requested from the browser the url which react native is getting the index.bundle from (the one in config settings in device app) and found that it was reachable...
I'm using 0.25.0-rc
It is definitely working now.
Tested with 0.25.1
Look at the replies in the linked github issue.
Overall, I think the big problem was that once react-native team addressed the orginal issue that was introduced in 0.21, they changed the way you are supposed to build the application.
And if you did not change, the error was salient. So it was impossible to catch it during debug/build process.
Basically since Feb 2016, you are no longer supposed to pull react-native jar from maven repository. Instead, you need to point your gradle.build to the react-native jar from the npm-modules location
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../../node_modules/react-native/android"
}
}
}
and then
compile "com.facebook.react:react-native:+"
this combination of changes above, allowed me to link to the latest copy of the react-native jar, rather than pulling 0.20.1 from maven (and notice that 0.20.1 from maven had not been modified since feb 2016).
This is for apps created with react-native init or ejected from expo.
Start de app with:
react-native run-android
The emulator will show the red screen debugger connection error (that is why we are here in the first place).
With the emulator in focus press:
Ctrl+M
or from the shell issue:
adb shell input keyevent KEYCODE_MENU
The in app Developer Menu will appear:
Click in
Dev settings
Select the option:
Debug server host & port for device
And enter:
localhost:8081
Now we’ll make calls in port 8081 in the emulator go to the same port on the host machine.
From the shell do:
adb reverse tcp:8081 tcp:8081
Ready, just restart the app
react-native run-android