Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Reusable Service #6240

Closed
fohoffmann opened this issue Nov 26, 2020 · 5 comments
Closed

Create a Reusable Service #6240

fohoffmann opened this issue Nov 26, 2020 · 5 comments
Assignees

Comments

@fohoffmann
Copy link

fohoffmann commented Nov 26, 2020

Hello,
cloud you please help, I fail with the latest CAP tutorial at step 5 when the sqlite DB shall bit initialized. Details see below.
Thank you!

Details:

Tutorial URL: https://developers.sap.com/tutorials/cp-cap-java-reusable-service.html
Tutorial 4, Step 5, Point 2:
https://developers.sap.com/tutorials/cp-cap-java-reusable-service.html#112655b0-e3d1-4146-a5dd-270744dea469

Issue:
user: products-service $ cds deploy --to sqlite
[ERROR] Cannot find module 'sqlite3'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at _loadSqlite (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:9:15)
at Promise (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:31:20)
at new Promise ()
at _new (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:30:10)
at SQLiteDatabase.acquire (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:156:19)
at SQLiteDatabase. (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:110:29)

Solution in #6029 does not help, cds is on latest version:

user: products-service $ cds -v
@sap/cds: 4.3.0
@sap/cds-compiler: 1.45.0
@sap/cds-dk: 3.2.1
@sap/cds-foss: 2.2.0
@sap/cds-reflect: 2.13.3
@sap/cds-runtime: 2.6.8
Node.js: v10.22.1
home: /extbin/npm/globals/lib/node_modules/@sap/cds
products-service-cds: 1.0.0

Other tries:

  • Installing sqlite globally (npm install -g --save-dev sqlite3) does not help
  • Creating the DB with sqlite sqlite.db and then create tables with .read schema.sql does not help (tables are created, but CAP seems to use other table names , which then later leads to "table not found" and http 500 errors)

Build log is attached in the comment

@fohoffmann
Copy link
Author

build-output.log

@chgeo
Copy link

chgeo commented Nov 27, 2020

This happens only in Studio and is caused by a double installation of @sap/cds in different locations. We are already in contact with the Studio team to find a solution.
For now, to unblock you, you can either

  • Run npm install in your application's root directory.
  • Or run unset NODE_PATH in your terminal. Note that you need to do this in every new terminal window, or make the change persistent by appending this line to your ~/.bashrc

@ramadasupuli
Copy link

I did npm install and but still same issue. Issue not resolved.

user: products-service $ npm install
removed 308 packages and audited 120 packages in 1.963s

2 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

user: products-service $ npm install --save-dev sqlite3
npm WARN deprecated request@2.88.2: request has been deprecated, see request/request#3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN lifecycle The node binary used for scripts is /extbin/bin/node but npm is using /opt/nodejs/node-v10.22.1-linux-x64/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

sqlite3@5.0.0 install /home/user/projects/products-service/node_modules/sqlite3
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
[sqlite3] Success: "/home/user/projects/products-service/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node" is installed via remote

  • sqlite3@5.0.0
    updated 1 package and audited 120 packages in 4.066s
    found 0 vulnerabilities

user: products-service $ cds deploy --to sqlite
[ERROR] Cannot find module 'sqlite3'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at _loadSqlite (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:9:15)
at Promise (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:31:20)
at new Promise ()
at _new (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:30:10)
at SQLiteDatabase.acquire (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:156:19)
at SQLiteDatabase. (/extbin/npm/globals/lib/node_modules/@sap/cds-runtime/lib/sqlite/Service.js:110:29)

user: products-service $

@ramadasupuli
Copy link

Thanks

unset NODE_PATH worked for me.

This happens only in Studio and is caused by a double installation of @sap/cds in different locations. We are already in contact with the Studio team to find a solution.
For now, to unblock you, you can either

  • Run npm install in your application's root directory.
  • Or run unset NODE_PATH in your terminal. Note that you need to do this in every new terminal window, or make the change persistent by appending this line to your ~/.bashrc

Thanks unset NODE_PATH worked for me

@fohoffmann
Copy link
Author

I've continued and finished the tutorial by switching directly to HANA (preponed step 7), which was fine for me since I anyway was not interested in the sqlite part so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants