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 require other packages (phantomjs-node) installed globally #46

Open
cloudgen opened this issue May 14, 2017 · 2 comments
Open

Cannot require other packages (phantomjs-node) installed globally #46

cloudgen opened this issue May 14, 2017 · 2 comments

Comments

@cloudgen
Copy link

cloudgen commented May 14, 2017

I use the following script to install the kernel to jupyterhub , nodeJS version 4.2.6 , Jupyter 5.1 :

  cd ~
  git clone https://github.com/notablemind/jupyter-nodejs.git
  sudo mv ~/jupyter-nodejs /etc/
  cd /etc/jupyter-nodejs/
  sudo npm install 
  sudo npm run build
  sudo npm run build-ext
  cd /etc/jupyter-nodejs/
  sudo node install.js /usr/local/share/jupyter/kernels/nodejs/

Most of the functions works properly, except when I install phantomjs-node, I tried to require the this package in jupyterhub,

require('phantom');

The error message is as following:

Error: Cannot find module 'phantom'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at /etc/jupyter-nodejs/build/context.js:78:16
    at require (/etc/jupyter-nodejs/build/context.js:58:27)
    at evalmachine.<anonymous>:1:1
    at Object.exports.runInContext (vm.js:44:17)
    at Context.rawRun (/etc/jupyter-nodejs/build/context.js:184:30)
    at Domain.<anonymous> (/etc/jupyter-nodejs/build/context.js:204:27)

(Updated)
I figure out the solution here, modify the kernel.json to include NODE_PATH as env:

{
  "argv": [
    "node",
    "/etc/jupyter-nodejs/build/run.js",
    "{connection_file}"
  ],
  "display_name": "NodeJS 4.3.10",
  "language": "javascript",
  "env":{
    "NODE_PATH" : "/usr/local/lib/node_modules"
  }
}
@jenningsanderson
Copy link

Yes, I just spent a long time debugging the same issue. Does jupyter-nodejs not by default look for global modules in /usr/lib/node_modules or /usr/local/lib/node_modules?

Further, I'm running it with jupyterhub, and it seems that whoever compiles it wins... meaning it was only looking in MY home directory's node_modules for modules; other users could not load modules from their local node_modules folder.

@Amertz08
Copy link

+1 Should maybe add directions for this to the docs imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants