Ooooh thanks muchly, let me try those changes and get back to you
C
CannibalKush
@CannibalKush
0
Reputation
3
Posts
776
Profile views
0
Followers
0
Following
Posts made by CannibalKush
-
RE: Local scripts not being found by require.
-
RE: Local scripts not being found by require.
Want to add my config.js being loaded on startup does include both localFileAccess and allowModules: "*"
{ "allowLocalFileAccess": true, "extensions": { "tasks": { "allowedModules": "*" }, "scripts": { "allowedModules": "*" }, "fs-store": { "dataDirectory": "data", "syncModifications": true } }, "store": { "provider": "fs" }, "logger": { "console": { "transport": "console", "level": "debug" }, "file": { "transport": "file", "level": "info", "filename": "logs/log.txt" }, "error": { "transport": "file", "level": "error", "filename": "logs/error.txt" } }, "tasks": { "allowedModules": "*" } }
-
Local scripts not being found by require.
Hi guys. When I try to load a script on my local filesystem as described by this tutorial: https://jsreport.net/blog/using-local-scripts-and-other-resources
I use the code as follows:
var customerSchema = require('/jsreport/models/customer.js');
This, of course, doesn't work and gives me the output:
Error while executing user script. Unable to find module /jsreport/models/customer.js Searched paths: /jsreport/models/customer.js /jsreport/models/customer.js /app/jsreport/models/customer.js /app/jsreport/models/customer.js /app/jsreport/models/customer.js
When I try to open the file using this code, though:
var data = fs.readFileSync(path.join(__appDirectory, '../jsreport/models/customer.js'));
Then the file is read correctly, although it's read as a text file and thus not executable (so not useful)
How can I load js from the local file system correctly?