Trying to work with the oauth2orize package. Running into some problems specifically here.
Here's the full error output:
D:\snapshot\Code\temp\pkg-oauth2orize\node_modules\oauth2orize\lib\index.js:39
fs.readdirSync(__dirname + '/grant').forEach(function(filename) {
^
Error: Directory 'D:\Code\temp\pkg-oauth2orize\node_modules\oauth2orize\lib\grant' was not included into executable at compilation stage. Please recompile adding it as asset or script.
at error_ENOENT (evalmachine.<anonymous>:0:0)
at readdirFromSnapshot (evalmachine.<anonymous>:0:0)
at Object.fs.readdirSync (evalmachine.<anonymous>:0:0)
at Object.<anonymous> (D:\snapshot\Code\temp\pkg-oauth2orize\node_modules\oauth2orize\lib\index.js:39:4)
at Module._compile (module.js:571:32)
at Module._compile (evalmachine.<anonymous>:0:0)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
I've tried adding every combination / variation of globs I could think of which would point to the node_modules/oauth2orize/lib/grant directory (windows slashes, recursive from a higher folder, full paths instead of relative, including the files inside that folder directly, grabbing the entirety of node_modules/**/*, etc), but I haven't found the right combination yet. Moving it out of node_modules and into a local libs folder didn't help, either (but I didn't really expect that to work).
Is my pkg property in package.json misconfigured, or is it something else?
Can reproduce by sending the following through pkg:
// package.json
{
"name": "pkg-oauth2orize",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"oauth2orize": "^1.8.0"
},
"pkg": {
"scripts": [
// obviously way too many entries here,
// just wanted to show a few of the things i tried,
// some as a group, some separately
"node_modules/oauth2orize/**/*.js",
"node_modules/oauth2orize/lib/grant",
"node_modules/oauth2orize/lib/grant/",
"node_modules/oauth2orize/lib/grant/*",
"node_modules/oauth2orize/lib/grant/*.js",
"node_modules/oauth2orize/lib/grant/**/*.js",
"node_modules/oauth2orize/lib/grant/code.js",
"node_modules/oauth2orize/lib/grant/token.js"
]
}
}
// index.js
require('oauth2orize');
If I go in and re-write the oauth2orize code to do the following instead, it works fine (but I'd like to avoid this, if at all possible):
exports.grant = {};
exports.grant.__defineGetter__('code', function() {
return require('./grant/code');
});
exports.grant.__defineGetter__('token', function() {
return require('./grant/token');
});
// alias grants
exports.grant.authorizationCode = exports.grant.code;
exports.grant.implicit = exports.grant.token;
exports.exchange = {};
exports.exchange.__defineGetter__('authorizationCode', function() {
return require('./exchange/authorizationCode');
});
exports.exchange.__defineGetter__('clientCredentials', function() {
return require('./exchange/clientCredentials');
});
exports.exchange.__defineGetter__('password', function() {
return require('./exchange/password');
});
exports.exchange.__defineGetter__('refreshToken', function() {
return require('./exchange/refreshToken');
});
// alias exchanges
exports.exchange.code = exports.exchange.authorizationCode;
Have a sort of similar issue with cache-manager. This error message occurs at runtime after pkg completes with warnings:
Error: Cannot find module './stores/memory'
Stems from here, and works fine if I modify the code to just require('./stores/memory') directly instead of dynamically.
Can't seem to come up with the right blob to include the asset / scripts for this module either. Tried the following for both pkg.assets and pkg.scripts in package.json without any luck:
"node_modules/cache-manager/**/*.js",
"node_modules/cache-manager/lib/stores/memory.js"
Here's a quick example to reproduce:
// package.json
{
"name": "pkg-cache-manager-test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"cache-manager": "^2.4.0"
},
"devDependencies": {
"pkg": "^3.0.5"
},
"scripts": {
"pkg": "pkg index.js"
},
"pkg": {
"scripts": [
"node_modules/cache-manager/**/*.js",
"node_modules/cache-manager/lib/stores/memory.js"
]
}
}
// index.js
const cacheManager = require('cache-manager');
const memoryCache = cacheManager.caching({
store: 'memory',
});
Added support for oauth2orize. Please try again with [email protected].
LGTM for oauth2orize, thanks for the work!
Still having problems with cache-manager, but that one is much simpler to solve than oauth2orize was, so this will save us some time.
Hi, can you add support for "cache-manager" as well, as it seems to be still an issue.
Hi Can you add support for "soap" as well.
Getting the following error
Error: File '/**/MY_SOAP_APP/node_modules/soap/lib/security/templates/wsse-security-header.ejs' was not included into executable at compilation stage. Please recompile adding it as asset or script.
at error_ENOENT (pkg/prelude/bootstrap.js:422:17)
at readFileFromSnapshot (pkg/prelude/bootstrap.js:646:29)
at Object.fs.readFileSync (pkg/prelude/bootstrap.js:689:18)
at Object.(/snapshot/MY_SOAP_APP/node_modules/soap/lib/security/WSSecurityCert.js:8:49)
@igorklopov "cache-manager" is still an issue here.
Hi, I have a similar issue with node-windows. When I run .exe file I get "
_my personal address_/node_modules/node-windows/bin/winsw/winsw.exe was not included into executable at compilation stage
". I tried adding my .js file to the .json file as "bin" and the "windw.exe" address as pkg assets. But it didn't help.
the .js file under the name of "windowsServiceInstaller.js"
`
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'tes',
description: 'tes',
script: 'C:\\Users\\Fakhreddin\\OneDrive\\Tart Scratch\\Scratch for Expo\\developer files\\bundle\\Deploy Files\\bin\\Tart Education Scratch\\server_E.js'
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();
`
and my package.json
`
{
"name": "service_ins",
"version": "1.0.0",
"description": "",
"main": "windowsServiceInstaller.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"node-windows": "^0.1.14"
},
"pkg": {
"assets": "./node_modules/node-windows/bin/winsw/winsw.exe"
},
"bin": "windowsServiceInstaller.js"
}
`
I run "pkg ." in the directory where both .js and .json files and node_modules folder are present. But I get the mentioned error when I run the .exe. I also tried running it as administrator. The .js code runs perfectly with "node windowsServiceInstaller.js" in cmd.
Any suggestions will be really appreciated. Thanks.
the example in this repository (https://github.com/zeit/pkg/tree/master/examples/express), when pkg to a single executable also fails,
Error: File or directory 'C:\**\repos\pkg\examples\express\views\index.html' was not included into executable at compilation stage. Please recompile adding it as asset or script.
Most helpful comment
Hi Can you add support for "soap" as well.
Getting the following error