Pkg: Cannot find module '../build/Release/hcaptha.node'

Created on 15 Jan 2018  路  5Comments  路  Source: vercel/pkg

Hi,
I'm a new developer to use pkg , after I use pkg to package my nodejs project , I got an executable file named app, when I run it with ./app, I got a problem like this:

pkg/prelude/bootstrap.js:1172
      throw error;
      ^

Error: Cannot find module '../build/Release/hcaptha.node'
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 Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1269:46)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at Module.require (pkg/prelude/bootstrap.js:1153:31)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/snapshot/scc-b2b/node_modules/ccap/lib/hcap.js:0)
    at Module._compile (pkg/prelude/bootstrap.js:1243:22)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

How can I solve this problem? Can you give me some suggestions, thanks a lot !

Most helpful comment

cp node_modules/**/*.node ./

All 5 comments

cp node_modules/**/*.node ./

Thanks for your replay, unfortunately, after I do this, I got another problem:

pkg/prelude/bootstrap.js:1172
      throw error;
      ^

Error: There are no suitable editions for this environment:
opts: { cwd: '/snapshot/scc-b2b/node_modules/extract-opts',
  package: 'extract-opts' }
editions: [ { description: 'Source + ESNext + Require',
    entry: 'source/index.js',
    directory: 'source',
    syntaxes:
     [ 'javascript',
       'esnext',
       'require',
       'const',
       'destructuring',
       'defaults' ] },
  { description: 'Babel Compiled + ES2015 + Require',
    entry: 'es2015/index.js',
    directory: 'es2015',
    syntaxes: [ 'javascript', 'es2015', 'require' ] } ]
failures: [ Error: Failed to load the edition due to a load error:
  edition: { description: 'Source + ESNext + Require',
    entry: 'source/index.js',
    directory: 'source',
    syntaxes:
     [ 'javascript',
       'esnext',
       'require',
       'const',
       'destructuring',
       'defaults' ] }
  error: 'Error: Cannot find module \'/snapshot/scc-b2b/node_modules/extract-opts/source/index.js\'\n    at Function.Module._resolveFilename (module.js:469:15)\n    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1269:46)\n    at Function.Module._load (module.js:417:25)\n    at Module.require (module.js:497:17)\n    at Module.require (pkg/prelude/bootstrap.js:1153:31)\n    at Object.require (internal/module.js:20:19)\n    at requireEdition (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:138:15)\n    at requireEditions (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:179:11)\n    at Object.requirePackage (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:207:9)\n    at Object.<anonymous> (/snapshot/scc-b2b/node_modules/extract-opts/index.js:3:38)\n    at Module._compile (pkg/prelude/bootstrap.js:1243:22)\n    at Object.Module._extensions..js (module.js:579:10)\n    at Module.load (module.js:487:32)\n    at tryModuleLoad (module.js:446:12)\n    at Function.Module._load (module.js:438:3)\n    at Module.require (module.js:497:17)'
      at DetailedError.Error (native)
      at new DetailedError (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:28:109)
      at requireEdition (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:141:26)
      at requireEditions (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:179:11)
      at Object.requirePackage (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:207:9)
      at Object.<anonymous> (/snapshot/scc-b2b/node_modules/extract-opts/index.js:3:38)
      at Module._compile (pkg/prelude/bootstrap.js:1243:22)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
      at Module.require (module.js:497:17)
      at Module.require (pkg/prelude/bootstrap.js:1153:31)
      at require (internal/module.js:20:19)
      at Object.<anonymous> (/snapshot/scc-b2b/node_modules/getmac/es5/lib/getmac.js:6:26)
      at Module._compile (pkg/prelude/bootstrap.js:1243:22),
  Error: Failed to load the edition due to a load error:
  edition: { description: 'Babel Compiled + ES2015 + Require',
    entry: 'es2015/index.js',
    directory: 'es2015',
    syntaxes: [ 'javascript', 'es2015', 'require' ] }
  error: 'Error: Cannot find module \'/snapshot/scc-b2b/node_modules/extract-opts/es2015/index.js\'\n    at Function.Module._resolveFilename (module.js:469:15)\n    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1269:46)\n    at Function.Module._load (module.js:417:25)\n    at Module.require (module.js:497:17)\n    at Module.require (pkg/prelude/bootstrap.js:1153:31)\n    at Object.require (internal/module.js:20:19)\n    at requireEdition (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:138:15)\n    at requireEditions (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:179:11)\n    at Object.requirePackage (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:207:9)\n    at Object.<anonymous> (/snapshot/scc-b2b/node_modules/extract-opts/index.js:3:38)\n    at Module._compile (pkg/prelude/bootstrap.js:1243:22)\n    at Object.Module._extensions..js (module.js:579:10)\n    at Module.load (module.js:487:32)\n    at tryModuleLoad (module.js:446:12)\n    at Function.Module._load (module.js:438:3)\n    at Module.require (module.js:497:17)'
      at DetailedError.Error (native)
      at new DetailedError (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:28:109)
      at requireEdition (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:141:26)
      at requireEditions (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:179:11)
      at Object.requirePackage (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:207:9)
      at Object.<anonymous> (/snapshot/scc-b2b/node_modules/extract-opts/index.js:3:38)
      at Module._compile (pkg/prelude/bootstrap.js:1243:22)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
      at Module.require (module.js:497:17)
      at Module.require (pkg/prelude/bootstrap.js:1153:31)
      at require (internal/module.js:20:19)
      at Object.<anonymous> (/snapshot/scc-b2b/node_modules/getmac/es5/lib/getmac.js:6:26)
      at Module._compile (pkg/prelude/bootstrap.js:1243:22) ]
    at DetailedError.Error (native)
    at new DetailedError (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:28:109)
    at requireEditions (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:186:8)
    at Object.requirePackage (/snapshot/scc-b2b/node_modules/editions/es2015/index.js:207:9)
    at Object.<anonymous> (/snapshot/scc-b2b/node_modules/extract-opts/index.js:3:38)
    at Module._compile (pkg/prelude/bootstrap.js:1243:22)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at Module.require (pkg/prelude/bootstrap.js:1153:31)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/snapshot/scc-b2b/node_modules/getmac/es5/lib/getmac.js:6:26)
    at Module._compile (pkg/prelude/bootstrap.js:1243:22)
    at Object.Module._extensions..js (module.js:579:10)

Is my path problem?

Set assets in package.json:

"pkg": {
"assets": [
  "node_modules/extract-opts/**"
]
}

I tried to set assets in package.json, but it didn't work.

I have same errors I didn't had before, but I didn't work for some months, so I don't know when the errors occurred in pkg or my software versions and I am irritated about :/

https://github.com/zeit/pkg/issues/334

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ydubois-fr picture ydubois-fr  路  4Comments

gillez picture gillez  路  4Comments

Ks89 picture Ks89  路  4Comments

hellower picture hellower  路  3Comments

j-brown picture j-brown  路  4Comments