Directory was not included into executable at compilation stage

See original GitHub issue

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;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
amtdevopscommented, Apr 4, 2018

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.<anonymous> (/snapshot/MY_SOAP_APP/node_modules/soap/lib/security/WSSecurityCert.js:8:49)

2reactions
igorklopovcommented, Jun 26, 2017

Added support for oauth2orize. Please try again with pkg@4.1.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not included into executable at compilation stage ... - GitHub
Not included into executable at compilation stage. ... I get Not more than one entry file/directory is expected when I run with pkg...
Read more >
Node.js vercel/pkg express 'return 0 error' and fastify errors ...
Node.js vercel/pkg express 'return 0 error' and fastify errors. Error: File or folder not included into executable during compilation stage.
Read more >
index.html not included in package error while running the ...
Error: File or directory '/**/express/views/index.html' was not included into executable at compilation stage. Please recompile adding it as ...
Read more >
pkg - npm
This command line interface enables you to package your Node.js project into an executable that can be run even on devices without Node.js ......
Read more >
Compiling a Node.js Application into an .exe File - Section.io
First, create a directory called “executable” and create files and folders as shown in the folder structure below. Initialize the project with:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found