How to fix erro while running sth-comet? - fiware

I am trying to install and configure STH-Comet, but I am having difficulties and I could not solve it.
I'm following the existing tutorial. And some errors occur in the process. I would like your help if possible.
After cloning the repository and entering the directory, when I run the command: npm install, two situations occur:
1- If it is not as root the errors are presented:
2 - If it is as root the errors increase, they are:
I also tried to install and configure via rpm. I do not have the above errors, but when I run ./bin/sth the following error appears.
`` `/opt/sth/node_modules/logops/lib/logops.js:27
let opts = merge({
^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/opt/sth/lib/sth.js:27:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)` ``
How can I solve this?

Let me share the procedure I follow, in the case it helps.
It has been done in a CentOS 7.5.1804 system.
Asumming MongoDB is up and running in that system.
All command runs as not privileged user (i.e. I'm not root)
Node environment (installed through nvm):
$ node --version
v8.15.1
$ npm --version
6.4.1
First, download the code:
git clone https://github.com/telefonicaid/fiware-sth-comet.git
Then, install packages:
cd fiware-sth-comet
npm install
Next, edit config.js to configure STH (look STH for details about this file). I have used config.js "as is" from the repository.
Finally, run the service:
npm start
If log shows a message like this, then it has been started correctly:
time=2019-04-29T20:12:18.745Z | lvl=INFO | corr=n/a | trans=n/a | op=OPER_STH_SERVER_START | from=n/a | srv=n/a | subsrv=n/a | comp=STH | msg=Server started at http://localhost:8666
You can check it's running with a "dummy" request. For instance:
curl -H 'fiware-service: foo' -H 'fiware-servicepath: bar' 'localhost:8666/STH/v1/contextEntities/type/myType/id/myEntity/attributes/temperature?hLimit=3&hOffset=0&dateFrom=2017-10-16T00:00:00.000Z&dateTo=2017-10-26T23:59:59.999Z'

Related

Why am I getting this error with npm, and how do I solve it?

I am trying to add a PayPal system into my html website. I am following this tutorial: https://www.youtube.com/watch?v=DNM9FdFrI1k&list=PL4eNesgScjZb3oktJK1786zI4nSET_tas&index=4
I am 9:10 into the video, and when I run npm run devStart as shown in the video, I get the following error:
PS C:\Users\dipla\OneDrive\Desktop\USB\Argo & coding\Examples\Web design\paypal-checkout> npm run devStart
> paypal-checkout#1.0.0 devStart
> nodemon server.js
The system cannot find the path specified.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\dipla\OneDrive\Desktop\USB\nodemon\bin\nodemon.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
I have node.js installed and I added its location to my environmental variables.
This is my first time using npm and Node.js
EDIT
I finally found what is causing the error, but I don't know how to fix it.
Here's what's happening:
When I run npm i express ejs dotenv #paypal/checkout-server-sdk it installs the node_modules folder in my project, it places the files where you would expect, which in my case is:
C:\Users\dipla\OneDrive\Desktop\USB\Argo & coding\Examples\Web design\paypal-checkout\node_modules
But the computer is looking for the \node_modules files in 'C:\Users\dipla\OneDrive\Desktop\USB\nodemon\bin\nodemon.js'
Normally you would see this error if you run the commands in the terminal from the wrong directory, however my terminal says
PS D:\USB\Argo & coding\Examples\Web design\paypal-checkout>
and when I run dir I get
PS D:\USB\Argo & coding\Examples\Web design\paypal-checkout> dir
Directory: D:\USB\Argo & coding\Examples\Web design\paypal-checkout
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2021-12-13 11:50 AM node_modules
d----- 2021-12-09 6:57 PM views
-a---- 2021-12-13 11:50 AM 128194 package-lock.json
-a---- 2021-12-13 11:50 AM 402 package.json
-a---- 2021-12-13 11:25 AM 251 server.js
So, I tried moving the node_modules folder into the directory / my computer is looking, and it worked, however, this is not where I want to keep the node_modules files. It is a really bad location because when I make my website live, the mode_modules folder will not be inside my project folder, so it wont be included.
note:
I am running this project from my USB. If I create the project from scratch NOT on my USB (directly on my desktop), I get the following error:
PS C:\Users\evand\Desktop\paypal-checkout> npm run devStart
> paypal-checkout#1.0.0 devStart
> nodemon server.js
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'node_modules/express'
Require stack:
- C:\Users\evand\Desktop\paypal-checkout\server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\evand\Desktop\paypal-checkout\server.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\evand\\Desktop\\paypal-checkout\\server.js' ]
}
[nodemon] app crashed - waiting for file changes before starting...
So, my new question is: How do I make npm / my computer look for node_modules in a different directory?
I saw this solution, as you are using an external drive, this must be the problem
getting "Error: EINVAL: invalid argument, read" for "npm install --save-dev eslint --verbose"
"Since you are using drive letter I:, you might be on a portable drive. I had the same problem using an USB-Stick formatted on FAT32. I solved it reformatting to NTFS."

json nmp package not working

I am using json npm package to update package.json file.
Using following commands
json -f package.json -I -e this.dependencies.data-version=\"1.0.0.1\"
Getting following error message
undefined:2
this.dependencies.'data-version'="1.0.0.1"
^^^^^^^^^^
SyntaxError: Unexpected string
at new Function (<anonymous>)
at main (C:\Users\SEUser2\AppData\Roaming\npm\node_modules\json\lib\json.js:
1289:27)
at Object.<anonymous> (C:\Users\SEUser2\AppData\Roaming\npm\node_modules\jso
n\lib\json.js:1683:5)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
I observer that if field name contains '-' character if creates issue.
How to run above command escaping '-' character ?
The best way I've found to update outdated packages in the package.json is to use: npm-check
npm-check -u
Which will let you interactively update the packages you want to update.
Can you try using this.dependencies['data=version'] instead

Global NPM command missing module: Contentful sync fails

I've globally installed an NPM module like so:
sudo npm install -g contentful-space-sync
The install flags a warning, but not sure if this is an issue:
npm WARN peerDependencies The peer dependency stream-browserify#* included from bl will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
contentful-space-sync#3.0.0 node_modules/contentful-space-sync
├── bluebird#3.1.1
├── yargs#3.31.0 (camelcase#2.0.1, window-size#0.1.4, y18n#3.2.0, decamelize#1.1.2, string-width#1.0.1, os-locale#1.4.0, cliui#3.1.0)
├── npmlog#2.0.0 (ansi#0.3.1, gauge#1.2.4, are-we-there-yet#1.0.5)
├── contentful-batch-libs#2.0.0 (contentful-management#0.7.1, contentful#1.2.1)
└── lodash#3.10.1
Install seems to work. To run the module, it's easiest to create a config file for it, which I did:
{
"sourceSpace": "xxxxxxxx",
"destinationSpace": "xxxxxxxx",
"sourceDeliveryToken": "xxxxxxxx",
"managementToken": "xxxxxxxx"
}
Now I run the module like this:
contentful-space-sync --config config.json
But I get the following error:
module.js:339
throw err;
^
Error: Cannot find module 'babel-register'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/contentful-space-sync/index.js:5:5)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/contentful-space-sync/bin/space-sync:4:20)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3
I've never had something like this for a globally installed module. Why can't it find a module it needs and how do I fix this?
this was a bad release. We're aware of the issue and working on a fix.
For now the best thing is to use 2.1.9. You can install it with npm install -g contentful-space-sync#2.1.9

Error When Executing Gulp on Mac OS X

Having trouble running Gulp, and not quite sure what the issue is here. I've Googled the error, yet all forums that have come up haven't fixed my issue.
Here's the relevant install info:
npm -v
2.11.3
node -v
v0.12.7
node -p process.versions
{ http_parser: '2.3',
node: '0.12.7',
v8: '3.28.71.19',
uv: '1.6.1',
zlib: '1.2.8',
modules: '14',
openssl: '1.0.1p' }
node -p process.platform
darwin
node -p process.arch
x64
And the error I'm getting when executing Gulp:
Error: `libsass` bindings not found in /PATH/TO/node_modules/gulp-sass/node_modules/node-sass/vendor/darwin-x64-14/binding.node. Try reinstalling `node-sass`?
at Object.sass.getBinaryPath (/PATH/TO/node_modules/gulp-sass/node_modules/node-sass/lib/extensions.js:148:11)
at Object.<anonymous> (/PATH/TO/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:16:36)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/PATH/TO/node_modules/gulp-sass/index.js:163:21)
at Module._compile (module.js:460:26)
Kind of lost on what to do next...
Try running npm rebuild node-sass after npm install node-sass.

Error: Cannot find module 'mysql'

in windows server 2008 i use nodejs to run my js file so to run my js need to have mysql so i installed mysql with command: npm install mysql
after installation there is this log:
C:\Users\lol>npm install mysql
npm http GET https://registry.npmjs.org/mysql
npm http 304 https://registry.npmjs.org/mysql
npm http GET https://registry.npmjs.org/bignumber.js/1.0.1
npm http GET https://registry.npmjs.org/require-all/0.0.3
npm http 304 https://registry.npmjs.org/require-all/0.0.3
npm http 304 https://registry.npmjs.org/bignumber.js/1.0.1
mysql#2.0.0-alpha9 node_modules\mysql
├── require-all#0.0.3
└── bignumber.js#1.0.1
But evry time i want to run my js i have this error:
C:\Users\lol>node D:\node\npauthapi.js
module.js:340
throw err;
^
Error: Cannot find module 'mysql'
at Function.Module._resolveFilename (module.js:338:15
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (D:\node\npauthapi.js:1:75)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
You can do a global install to avoid this problem:
npm install -g mysql
you installed it locally in folder c:\users\lol, so it's not available in your folder d:\node
Place your .js file in the same location where you ran the command (npm install mysql). This is because after the installation, the MySQL node_modules folder will be created in that location so you should place the .js file there so that while running, it can get the required modules from the node_modules folder.