Error: The app has not been configured with a WORKSPACE_ID environment variable - node.js

I've changed the workspace ID in both my env file as well as my app.js file just in case. I've installed all the necessary SDK's and have done everything according to the instructions here.
I swapped out the workspace files with my own workspace. But I made all the necessary changes including changing the workspace ID. Not quite sure why i'm still getting the error. Any help would be much appreciated!
Edited: Here are the changes I made to my code
Image

I had the same problem a few days ago. And, to solved this, you can paste the WORKSPACE_ID in this line too!
But, if you want use the .env file, make sure the are no spaces between = and the end of the line.
I will put the print of my app.js as an example to help you:
Actually, both ways work.
My example show this:
username = "<iwdiaowd-jioawjd-ioajgr-ogxgxajofa>"
password = "<xxxxxxxxxxxxxxxxxxxx>"
var workspace = "<59583409583495834590385394>"`
Try edit your .env:
WLP_SKIP_MAXPERMSIZE=true
VCAP_SERVICES={"conversation": [{"name": "conversation-service","label": "conversation","plan": "free","credentials": {"url": "https://gateway.watsonplatform.net/conversation/api","isStreaming": false,"password": "-ReplaceMe-","username": "-ReplaceMe-"}}]}
COLLECTION_NAME=workspace
WORKSPACE_ID=iwdiaowd-jioawjd-ioajgr-ogxgxajofa
LOGGING_ENABLED=false

Related

How do I get my Nodejs .env file recognized?

Well I started to learn how to create api rest
and when I want to call it in the proccess.env it doesn't recognize it.
I already have dotenv installed
this is how my .env file looks like
this is the error, I have tried with other ports but I get the same error .
my package.json
I also tried following:
require('dotenv').config({path: '../.env'});
require('dotenv').config({path: '../../.env'});
and all I get is this
enter image description here
I hope I made myself understood, I tried to search on yt but found no answer. Thank you for your time
You do not need to write it like that, you can just use it like this
import * as dotenv from 'dotenv'
dotenv.config()
this is possible because the default path is your root folder.
Also, you are supposed to put it in your root folder as it is stated by the creators, you can read it here.
However if you really want to use it in another directory, you can read through solution on this question.

updatesystem does not consider config json

I am trying to perform system update from command line with a json config but it seems that, no matter what I do,
the command does the exact same thing, which I suppose is running the update with the default platform settings.
For example, when I tried to perform my update without essential data("essential": "false" in json config), essential impexes are also being run.
I tried with an invalid json(that does not have json format) and the build was successfull.
I also tried giving as a paramter a json that does not exist and yet, the build was successfull and essential impexes were also run.
So, it seems to me that, no matter what I do, the json is not taken into account and the update works with the default platform settings.
This is the command I am using:
ant updatesystem -Dtenant=master -DconfigFile=Path/updatesystem.json
Am I doing something wrong or how can I pass my configuration during system update from command line ?
PS:
Hybris version: 6.7.0.25
I Think your JSON path is wrong and please try to do it like this.
ant updatesystem -DconfigFile=../custom/testcore/resources/updatesystem-configuration.json
The problem was caused by the fact that the "updatesystem" macro was overriden in a project specific file and the configFile property was not passed to the UpdatePlatformAntPerformableImpl during creation. That is why, regardless of my input for configFile property , nothing changed.
I fixed the problem by also passing the configFile in the constructor:
new de.hybris.ant.taskdefs.UpdatePlatformAntPerformableImpl("${tenant}", "${configFile}")

Editing the .env file using node.js

I have a check.env file, in which I have some variables like
SharedAccessKey=
I want to put a value in the check.env file from my node.js code. Articles on internet are there for updating at the running time of node.js, but my requirement is to change in the file and keep the file with changes made.
How can I accomplish that.
I got this link : How to change variables in the .env file dynamically in Laravel?
but it is in some other language, how can I do in node.js.
I was unable to find out the best solution so went with another solution of mine that I took.
I am using two files now both .env extensions and I am copying main .env file to another empty .env file (like check1.env to check2.env).
Any modifications I am making is in the second file (check2.env).
And I am using string replacement in the .env file, using fs.readLine() and getting the string and the data.replace(), this worked for me.
The reason to use two .env files is that even if I change in the second file, again by copying from the first file I will get same string search and will replace with a different value.
-- Please suggest if there is an any better approach. Thanks

Suave with netcoreapp2.0

I've been following this Suave tutorial:
https://legacy.gitbook.com/book/theimowski/suave-music-store/details
And in general this looks good. However, I was trying to make it work with Linux and for some reason I was unable to compile it with code when TargetFramework was set to "net461" (Target Framework not found), so I tried changing it to "netcoreapp2.0". It compiled, but I hit a problem later on:
https://theimowski.gitbooks.io/suave-music-store/content/en/css.html
At the end it says to add a WebPart:
pathRegex "(.*)\.(css|png)" >=> Files.browseHome
which fails for me. All compiles, but I get
This page isn’t working
localhost didn’t send any data.
I took a look at Suave's source code and it turned out that "Files.browseHome" searches for a file under "ctx.runtime.homeDirectory".
I noticed that this is set on my machine to:
/home/<my_user_name>/.nuget/packages/suave/2.2.1/lib/netstandard1.6
and obviously, that's not my project directory, so no wonder it couldn't find the file.
My question here is: what shall I do in order to make my Suave app handle my css/png files correctly using Files.browseHome ?
EDIT:
Just found out that replacing the WebPart with:
pathRegex "(.*)\.(css|png)" >=> Files.browse "/home/<my_username>/<path_to_my_project>/bin/Debug/netcoreapp2.0/"
works fine, but it looks ugly. Any idea how to make it better ? Basically I don't want to be forced to hardcode the absolute path anywhere.
I think the answer is to be found in https://suave.io/files.html, which suggests creating a config as follows:
let config =
{ defaultConfig with homeFolder = Some (Path.GetFullPath "./public") }
The path returned by Path.GetFullPath will depend on the current working directory that your app sees when it's started (which will, in turn, depend on how you start the app: from the command line, from a systemd unit file, etc.) There are too many possible variables here for me to be able to give you exact instructions, but if your startup method can cd into an appropriate folder before starting your Suave server, then that should solve your problem.
If you run into difficulties with getting the current working directory set correctly, then you could just hardcode the full path in the config:
let config =
{ defaultConfig with homeFolder = Some "/home/<your_username>/<path_to_your_project>/bin/Debug/netcoreapp2.0/" }
But that's kind of ugly, and not really portable (you'd have to modify that path again once you deploy the app). So I'd recommend the approach of making sure your start script does a cd to the right location, then using Path.GetFullPath with a relative path. Alternately, you could have a config file that gets read in at app startup where you specify the home path, or pass it in as an environment variable... All kinds of possibilities. Just make sure that your code can be handed some information on startup that specifies the correct "home" folder, and then put that in your Suave config as I've shown, and that should solve it.

touching a path name with varriable or other methode

I have a question about touching a path in a shell script. I'm making a script that clears some directories and add some files, now I'm trying to do this with touch /name/of/path instead of a find. I have some troubles with one of the paths this is becaus the last bit of the name changes in every file (the files are about working orders) now I tried some stuff like a variable or just the path with a * but it gives me an error
can anyone tell me if i need to change my variable for example.
the variable im currently using:
test='path/to/touch/annoy\ ing\ space*/'
and in my code I would like to execute this like
touch $test/test.txt
the error I get when running this is
touch: invalid option --'\'
I guess i get this option because there are \ in the varriabe but that is because there are spaces in the directory name I'm trying to enter.
I also tried something like this
touch path/to/touch/annoy\ ing\ space*/test.txt
but I also get an error when I try it like this, I read this is because I use a wildcard in touch and that isn't allowed. Can anyone confirm this?
If someone could give me an example or tip how to do this it would realy help me out. thanks in advance

Resources