Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '../build/Debug/pty.node' #256

Closed
imomaliev opened this issue Jan 7, 2019 · 21 comments
Closed

Cannot find module '../build/Debug/pty.node' #256

imomaliev opened this issue Jan 7, 2019 · 21 comments

Comments

@imomaliev
Copy link

Environment details

  • OS: Mac OS
  • OS version: 10.14.2
  • node-pty version: 0.8.0
  • electron version: 4.0.1

Issue description

export npm_config_target=4.0.1
# Download headers for Electron.
export npm_config_disturl=https://atom.io/download/electron
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron
# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true
HOME=~/.electron-gyp npm install

npm start


 WARNING  Compiled with 3 warnings                                                                                                                                                                9:13:22 PM

 warning  in ./node_modules/node-pty/lib/index.js

Critical dependency: the request of a dependency is an expression

 warning  in ./node_modules/node-pty/lib/utils.js

Critical dependency: the request of a dependency is an expression

 warning  in ./node_modules/node-pty/lib/utils.js

Critical dependency: the request of a dependency is an expression


App threw an error during load
Error: Cannot find module '../build/Debug/pty.node'
    at webpackEmptyContext (webpack:///./node_modules/node-pty/lib_sync?:2:10)
    at Object.loadNative (webpack:///./node_modules/node-pty/lib/utils.js?:22:81)
    at eval (webpack:///./node_modules/node-pty/lib/unixTerminal.js?:21:19)
    at Object../node_modules/node-pty/lib/unixTerminal.js (/Users/User/Project/dist_electron/index.js:1113:1)
    at __webpack_require__ (/Users/User/Project/dist_electron/index.js:20:30)
    at eval (webpack:///./node_modules/node-pty/lib/index.js?:14:20)
    at Object../node_modules/node-pty/lib/index.js (/Users/User/Project/dist_electron/index.js:1089:1)
    at __webpack_require__ (/Users/User/Project/dist_electron/index.js:20:30)
    at eval (webpack:///./src/background.ts?:15:66)
    at Module../src/background.ts (/Users/User/Project/dist_electron/index.js:1694:1)
@Tyriar
Copy link
Member

Tyriar commented Jan 7, 2019

What's the output of the npm install?

@imomaliev
Copy link
Author

imomaliev commented Jan 7, 2019

> node-pty@0.8.0 install /Users/User/Project/examples/electron/node_modules/node-pty
> node scripts/install.js

  CXX(target) Release/obj.target/pty/src/unix/pty.o
In file included from ../src/unix/pty.cc:20:
In file included from ../../nan/nan.h:203:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:337:28: warning: 'New' is deprecated: Use Isolate* version [-Wdeprecated-declarations]
  return v8::StringObject::New(value).As<v8::StringObject>();
                           ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:5241:3: note: 'New' has been explicitly marked deprecated here
  V8_DEPRECATED("Use Isolate* version",
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../src/unix/pty.cc:20:
../../nan/nan.h:1034:44: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
      v8::Local<v8::String> string = from->ToString();
                                           ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../src/unix/pty.cc:20:
../../nan/nan.h:1044:27: warning: 'WriteUtf8' is deprecated: Use Isolate* version [-Wdeprecated-declarations]
        length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
                          ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2753:3: note: 'WriteUtf8' has been explicitly marked deprecated here
  V8_DEPRECATED("Use Isolate* version",
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:154:39: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
  v8::String::Utf8Value file(info[0]->ToString());
                                      ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:154:25: warning: 'Utf8Value' is deprecated: Use Isolate version [-Wdeprecated-declarations]
  v8::String::Utf8Value file(info[0]->ToString());
                        ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2991:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:165:69: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
    v8::String::Utf8Value arg(argv_->Get(Nan::New<v8::Integer>(i))->ToString());
                                                                    ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:165:27: warning: 'Utf8Value' is deprecated: Use Isolate version [-Wdeprecated-declarations]
    v8::String::Utf8Value arg(argv_->Get(Nan::New<v8::Integer>(i))->ToString());
                          ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2991:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:176:69: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
    v8::String::Utf8Value pair(env_->Get(Nan::New<v8::Integer>(i))->ToString());
                                                                    ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:176:27: warning: 'Utf8Value' is deprecated: Use Isolate version [-Wdeprecated-declarations]
    v8::String::Utf8Value pair(env_->Get(Nan::New<v8::Integer>(i))->ToString());
                          ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2991:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:181:39: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
  v8::String::Utf8Value cwd_(info[3]->ToString());
                                      ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:181:25: warning: 'Utf8Value' is deprecated: Use Isolate version [-Wdeprecated-declarations]
  v8::String::Utf8Value cwd_(info[3]->ToString());
                        ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2991:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:186:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_col = info[4]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:187:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_row = info[5]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:195:16: warning: 'ToBoolean' is deprecated: Use maybe version [-Wdeprecated-declarations]
  if (info[8]->ToBoolean()->Value()) {
               ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2546:10: note: 'ToBoolean' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version",
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:230:22: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  int uid = info[6]->IntegerValue();
                     ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:231:22: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  int gid = info[7]->IntegerValue();
                     ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:315:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_col = info[0]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:316:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_row = info[1]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:360:21: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  int fd = info[0]->IntegerValue();
                    ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:363:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_col = info[1]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:364:26: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  winp.ws_row = info[2]->IntegerValue();
                         ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:387:21: warning: 'IntegerValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
  int fd = info[0]->IntegerValue();
                    ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2570:3: note: 'IntegerValue' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version", int64_t IntegerValue() const);
  ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:389:39: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations]
  v8::String::Utf8Value tty_(info[1]->ToString());
                                      ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
         ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:389:25: warning: 'Utf8Value' is deprecated: Use Isolate version [-Wdeprecated-declarations]
  v8::String::Utf8Value tty_(info[1]->ToString());
                        ^
/Users/User/.node-gyp/11.6.0/include/node/v8.h:2991:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/User/.node-gyp/11.6.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
../src/unix/pty.cc:489:21: warning: 'Call' is deprecated [-Wdeprecated-declarations]
  Nan::Callback(cb).Call(Nan::GetCurrentContext()->Global(), 2, argv);
                    ^
../../nan/nan.h:1595:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
25 warnings generated.
  SOLINK_MODULE(target) Release/pty.node

> electron@4.0.1 postinstall /Users/User/Project/examples/electron/node_modules/electron
> node install.js


> node-pty@0.8.0 postinstall /Users/User/Project/examples/electron/node_modules/node-pty
> node scripts/post-install.js

npm WARN node-pty-electron-example@1.0.0 No license field.

added 148 packages from 144 contributors and audited 204 packages in 7.701s
found 0 vulnerabilities

@Tyriar
Copy link
Member

Tyriar commented Jan 7, 2019

Strange, node-pty definitely works under Electron as VS Code has early builds working and the terminal works. Doesn't look like any node-pty-specific changes in the diff https://github.com/Microsoft/vscode/compare/electron-4.0.x

@imomaliev
Copy link
Author

imomaliev commented Jan 7, 2019

  • npm --version 6.5.0
  • node --version v11.6.0

FYI if I try to use https://github.com/Microsoft/node-pty/tree/master/examples/electron with
package.json

{
  "name": "node-pty-electron-example",
  "version": "1.0.0",
  "description": "A minimal node-pty Electron example",
  "main": "main.js",
  "scripts": {
    "start": "electron . --ignore-gpu-blacklist"
  },
  "repository": "https://github.com/Tyriar/node-pty",
  "author": "Tyriar",
  "dependencies": {
    "electron": "^4.0.1",
    "node-pty": "^0.8.0",
    "xterm": "^3.10.0"
  }
}

and do

HOME=~/.electron-gyp npm install
npm start

I get in electron dev tools

Uncaught Error: Cannot find module '../build/Debug/pty.node'
    at Module._resolveFilename (internal/modules/cjs/loader.js:584)
    at Function.Module._resolveFilename (/Users/User/node-pty/examples/electron/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:43)
    at Function.Module._load (internal/modules/cjs/loader.js:510)
    at Module.require (internal/modules/cjs/loader.js:640)
    at require (internal/modules/cjs/helpers.js:20)
    at Object.loadNative (utils.ts:17)
    at Object.<anonymous> (unixTerminal.ts:13)
    at Object.<anonymous> (unixTerminal.ts:279)
    at Module._compile (internal/modules/cjs/loader.js:693)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704)

@Tyriar
Copy link
Member

Tyriar commented Jan 7, 2019

node --version v11.6.0

Maybe this is the problem? it's only be tested on <= node 10?

@billdestein
Copy link

billdestein commented Jan 12, 2019

I had the same problem. I was seeing errors about "Cannot find module '../build/Debug/pty.node'.

It turns out that in my case, the error message is misleading. The code that loads the DLL (see the file utils.js in the node-pty code) actually found the Release version of the DLL, but couldn't load it because it was compiled with the wrong version of node. It did not report that error.. So the code went on to try loading the Debug version of the DLL, which did not exist, and that's the error message I saw.

Once I figured that out, the next step was to recompile node-pty with the latest node version. So I deleted my node_modules directory and ran "yarn". Surprisingly to me, that didn't fix the problem. After much Googling, I did this ...

npm rebuild node-pty --update-binary

and all was well. I don't know where the old DLL was being stashed such that it wasn't deleted when I deleted my node_modules directory. Can someone tell me?

@kof
Copy link

kof commented Jan 14, 2019

Same problem, I get this error :

    Cannot find module '../build/Debug/pty.node' from 'utils.js'

      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:221:17)
      at Object.loadNative (../../node_modules/node-pty/lib/utils.js:22:16)
      at Object.<anonymous> (../../node_modules/node-pty/lib/unixTerminal.js:21:19)

Summary of all failing tests
 FAIL  ../modules/babelhook/index.test.js
  ● Test suite failed to run

    Cannot find module '../build/Debug/pty.node' from 'utils.js'

      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:221:17)
      at Object.loadNative (../../node_modules/node-pty/lib/utils.js:22:16)
      at Object.<anonymous> (../../node_modules/node-pty/lib/unixTerminal.js:21:19)

And when I try to reinstall packages I get this:

error /Users/kof/work/XXX/XXX/node_modules/node-pty: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments:
Directory: /Users/kof/work/XXX/XXX/node_modules/node-pty
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.11.1 | darwin | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/kof/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/kof/work/XXX/XXX/node_modules/node-pty/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/kof/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/kof/.node-gyp/8.11.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/kof/.node-gyp/8.11.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/kof/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/kof/.node-gyp/8.11.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/kof/work/XXX/XXX/node_modules/node-pty',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc:489:21: warning: 'Call' is deprecated [-Wdeprecated-declarations]
  Nan::Callback(cb).Call(Nan::GetCurrentContext()->Global(), 2, argv);
                    ^
../../nan/nan.h:1595:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/unix/pty.cc:644:10: error: use of undeclared identifier 'openpty'
  return openpty(amaster, aslave, name, (termios *)termp, (winsize *)winp);
         ^
../src/unix/pty.cc:693:10: error: use of undeclared identifier 'forkpty'
  return forkpty(amaster, name, (termios *)termp, (winsize *)winp);
         ^
1 warning and 2 errors generated.
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/kof/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/kof/.nvm/versions/node/v8.11.1/bin/node" "/Users/kof/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/kof/work/XXX/XXX/node_modules/node-pty
gyp ERR! node -v v8.11.1

I tried with node latest v8 and latest v10. It started happening just a few days ago, not sure when exactly. I tried updainig macos command line tools to the latest available version and I am on macos 10.13.6

@haofo
Copy link

haofo commented Jan 15, 2019

I solved the error.

npm install --save-dev electron-rebuild

add a script in package.json

"scripts": {
  "rebuild": "electron-rebuild -f -w node-pty"
}

then

npm run rebuild

@Tyriar
Copy link
Member

Tyriar commented Jan 16, 2019

@haofo would this do the same as git clean -xfd && npm i? I haven't run into this personally

@haofo
Copy link

haofo commented Jan 17, 2019

@Tyriar the error i run into was due to the electron version did not match in my project.

"electron": "^3.0.7",
"node-pty": "^0.8.0",
"xterm": "^3.10.1"

when I downloaded node-pty/examples/electron and ran npm i && npm start, it was well.

@AvailCat
Copy link

AvailCat commented Feb 15, 2019

Double check your installed electron version. npm might install 4.0.2, 4.0.3 if you put ^4.0.1 in package.json without a lock file or it was updated.

@Tyriar
Copy link
Member

Tyriar commented Mar 1, 2019

So I think this is all related to not compiling with Electron's version of node or webpack not knowing about the .node file. These are both by design, feel free to propose a change to the documentation to make these issues more visible though.

@pattrickrice
Copy link

I am running into this error on my project and am not sure what the solution is here? I've tried npm run rebuild, cleaning node_modules, different versions of node, electron, etc.

@Tyriar
Copy link
Member

Tyriar commented Jun 25, 2019

You can comment out the try/catch and debug import to see the actual error, created #326 to improve the error you get.

@pattrickrice
Copy link

pattrickrice commented Jun 25, 2019

Thanks @Tyriar , what try catch would I comment out? Webpack's?
Edit: nevermind, found it here

@pattrickrice
Copy link

This happened to me when running karma tests. Unrelated, but my project migrated to jest and I just made a mock for the module. Solved the problem.

@mafischer
Copy link

mafischer commented Oct 9, 2019

node -v 10.16.3
npm -v 6.12.0

Upgrading to latest node-pty beta (0.9.0-beta27) and rebuilding electron via electron-rebuild (npx electron-rebuild) did the trick for me.

@remy90
Copy link

remy90 commented Dec 1, 2019

@Tyriar Not sure if its worth creating a new issue but mine is identical to the two logs provided. I lowered my node version, still to no avail:

node-pty -v 0.9.0
node -v 10.17.0
npm -v 6.12.1

OS: Ubuntu 19.10

@Tyriar
Copy link
Member

Tyriar commented Dec 2, 2019

This is a generic error that importing failed, in 0.9.0 the original release exception is re-thrown which should give more information: #340

You can create a new issue if it's not obvious from the error message.

@microsoft microsoft locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

11 participants