سؤال

I installed sqlite3 like this: npm install sqlite3

It succeded without any errors. Now, if I want to execute sqlite, I get the Following Exception:

enter image description here

It says "'module' is undefined". Am I missing something? I tried the exact same thing on OpenSUSE and it worked as expected.

هل كانت مفيدة؟

المحلول

The first problem is you're trying to run a node.js script using Windows' JScript implementation (this is the default file association in Windows). You need to run the script with node in one way or another. One way to do this is via the command prompt with node myscript.js.

The second problem is that you're trying to execute sqlite3.js which doesn't actually do anything except export the database client. Instead you need to write your own script (that lives in the parent directory of node_modules) that require()'s sqlite3 and uses that.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top