Error while running an exe compiled with PKG - javascript

im compiling a file with PKG. But whenever I try to run the file it gives this error.
Error
All versions are up to date.
I'm trying to run my simple javascript code on another computer and this error pops up.
Error: Cannot find module 'C:\snapshot\highu\OneDrive\Masaüstü\XXX\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64\node_sqlite3.node'
Require stack:
- C:\snapshot\highu\OneDrive\Masaüstü\XXX\node_modules\sqlite3\lib\sqlite3-binding.js
- C:\snapshot\highu\OneDrive\Masaüstü\XXX\node_modules\sqlite3\lib\sqlite3.js
- C:\snapshot\highu\OneDrive\Masaüstü\XXX\.\.\.\.\.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1955:46)
at Module._load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at Module.require (pkg/prelude/bootstrap.js:1855:31)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\snapshot\highu\OneDrive\Masaüstü\XXX\node_modules\sqlite3\lib\sqlite3-binding.js:4:17)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\snapshot\\highu\\OneDrive\\Masaüstü\\XXX\\node_modules\\sqlite3\\lib\\sqlite3-binding.js',
'C:\\snapshot\\highu\\OneDrive\\Masaüstü\\XXX\\node_modules\\sqlite3\\lib\\sqlite3.js',
'C:\\snapshot\\highu\\OneDrive\\Masaüstü\\XXX\\.\\.\\.\\.\\.js'
],
pkg: true
}
Node.js v18.5.0

Related

nest.js error when deploying start:prod to Digital Ocean App Platform

I have been trying to deploy my app to DO and I keep getting the error
Error: Cannot find module '/workspace/dist/main'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Function.Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
So I have tried different variations in the package.json within the start:prod command but cant get it to build complete
/
/dist/main
../dist/main
Does anyone have any experience with getting this to work?
start:prod sounds like it should be set to node dist/src/main. This usually is the case when there is a file from outside of src being compiled with src, and Typescript is maintaining the directory structure in the output directory.

I received this code error each time I tried to sart may project on vscode using parcel : 'ERR_DLOPEN_FAILED'

I'm new to parcel and I'm following a tutorial I downloaded parcel last version is not working I tried the version the instructor using but the same thing happened the
the output in the terminal is
Error: The specified module could not be found.
\\?\\D:\\Downloads\\starter\\node_modules#parcel\\source-map\\parcel_sourcemap_node\\artifacts\\index.win32-x64-msvc.node
at Module.\_extensions..node (node:internal/modules/cjs/loader:1243:18)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module.\_load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (D:\\Downloads\\starter\\node_modules\\v8-compile-cache\\v8-compile-cache.js:159:20)
at Object.\<anonymous\> (D:\\Downloads\\starter\\node_modules#parcel\\source- map\\parcel_sourcemap_node\\index.js:15:18)
at Module.\_compile (D:\\Downloads\\starter\\node_modules\\v8-compile-cache\\v8-compile-cache.js:192:30)
at Module.\_extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module.\_load (node:internal/modules/cjs/loader:878:12) {
code: 'ERR_DLOPEN_FAILED'
}
ive had the same error before,
i removed my node_modules package and then ran again, this worked for me

how to build python with node-gyp?

I've seen the official tutorial as well as this one showing how to build python from source and edit it with visual studio etc., but how do I build it with node-gyp to use it as a native application in node?
For example, in the tutorial, they tell you to download the source code, and then (in windows) type in that directory:
"PCbuild/build.bat"
and then that builds the Visual Studio solution and python in general etc., but now how do I do that with node-gyp? In general, to include external dependencies to build with node-gyp, you just include them in the binding.gyp file. For python, I first installed 64 bit (and later 32 bit, same error as below) python to C:/Python382, then I copied that folder to my another folder in my C++ application, and set the binding.gyp file to this (to get the include and libs):
{
"targets": [
{
"target_name": "addon",
"sources": [
"<!#(node -p \"var fs=require('fs'),path=require('path'),walk=function(r){let t,e=[],n=null;try{t=fs.readdirSync(r)}catch(r){n=r.toString()}if(n)return n;var a=0;return function n(){var i=t[a++];if(!i)return e;let u=path.resolve(r,i);i=r+'/'+i;let c=fs.statSync(u);if(c&&c.isDirectory()){let r=walk(i);return e=e.concat(r),n()}return e.push(i),n()}()};walk('./sources').join(' ');\")"
],
"libraries":[
"C:/Users/Coby/Documents/aa/atzmus/CPPtesting/other/ok/Python382/libs/python38.lib",
"C:/Users/Coby/Documents/aa/atzmus/CPPtesting/other/ok/Python382/libs/python3.lib",
"C:/Users/Coby/Documents/aa/atzmus/CPPtesting/other/ok/Python382/libs/_tkinter.lib"
],
"include_dirs": [
"C:/Users/Coby/Documents/aa/atzmus/CPPtesting/other/ok/Python382/include"
],
"dll_files": [
"C:/Users/Coby/Documents/aa/atzmus/CPPtesting/other/ok/Python382/python38.dll"
]
}
]
}
and my hello.cc file, which is the other source, simply includes Python.h. When I run this build using node-gyp build or node-gyp rebuild, it actually builds fine with no errors at all, but then when I copy over the file addon.node to my actual nodeJS server, which simply has the one line var addon = require("./addon"), I get the following error output in CMD (however, it works fine with no errors without including Python.h in my .cc source file):
internal/modules/cjs/loader.js:1197
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: \\?\C:\Users\Coby\Documents\aa\atzmus\testServer\addon.node is not a valid Win32 application.
\\?\C:\Users\Coby\Documents\aa\atzmus\testServer\addon.node
←[90m at Object.Module._extensions..node (internal/modules/cjs/loader.js:1197
:18)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:983:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:1023:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:72:18)←[39m
at Object.<anonymous> (C:\Users\Coby\Documents\aa\atzmus\testServer\oy.js:2:
9)
←[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:1
0)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:983:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)←[39m
The main part seems to be:
addon.node is not a valid Win32 application.
I tried doing this with python for 64bit windows, and for 32bit windows, my system in 64 bit, my nodeJS installation is 64 bit, but I also tried it with 32 bit note; I don't know how to fix this exactly, or if there is another way entirely to build python with node-gyp?
so:
What steps need to be taken in windows to build python through node-gyp, to be able to use python natively with nodejs without having to resort to child-process?

How can I load NAN libraries with Meteor?

How can I load NAN libraries with Meteor? Currently, I'm using this code:
greenworks = require('./imports/lib/lib/greenworks-osx64');
When I try to load a ".node" file, Meteor errors with this:
Error: Cannot find module './imports/lib/lib/greenworks-osx64'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at meteorInstall.imports.lib.greenworks.js (imports/lib/greenworks.js:13:25)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at meteorInstall.imports.lib.theculling.js (imports/lib/theculling.js:1:18)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at Module.Mp.import (/Users/jmeyer2k/.meteor/packages/modules/.0.7.5.8vojen++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16)
at meteorInstall.server.main.js (server/main.js:1:1)
What I've tried already: changing the path to different relative and absolute paths; checking code for references to ".js"

Possible issue with multer? Error: Router.use() requires callback

Building a site with yeoman angular-fullstack works great locally, but when I deploy and use the dist/release version it gives me this fun error on my server.
Error: Router.use() requires callback functions but got a [object Object]
at Function.proto.use (/home/bitnami/htdocs/dist/node_modules/express/lib/router/index.js:327:11)
at Object.<anonymous> (/home/bitnami/htdocs/dist/server/api/save/index.js:10:8)
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 Function.<anonymous> (/opt/bitnami/nodejs/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (/home/bitnami/htdocs/dist/server/routes.js:13:25)
It seams that it's failing on this line
router.use(multer({ dest: './public/uploads/'}));
Though it works locally completely fine? Has me a bit stumped.
Wonder if its related to multer? I have the node module installed.
Thoughts?
Recent versions of multer changed the API. If you look at the examples, you will see you now have to do something like:
var upload = multer({ dest: './public/uploads/'});
// ...
router.use(upload.single('foofield'));
Or upload.array() or upload.fields().

Categories