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

Node dependencies in package.json aren't found #31

Closed
holyjak opened this issue Jun 8, 2015 · 6 comments
Closed

Node dependencies in package.json aren't found #31

holyjak opened this issue Jun 8, 2015 · 6 comments

Comments

@holyjak
Copy link

holyjak commented Jun 8, 2015

Hello, is this kernel intended to be usable with a Node.js project? If that is the case as I assume, I expect it should be possible to start ijs in a node project (having package.json and some JS code) and have access to that code and dependencies declared in package.json. However that doesn't seem to be the case, as demonstrated here: https://github.com/jakubholynet/ijavascript-node-bug/blob/master/notebook.ipynb

Is there any way to get this work? (I would like to use Hydrogen to execute code in the context of my project)

Thank you!

Software versions:

ijs: 5.0.2
npm: 1.4.28
ipython: 3.1.0
OS: OS X 10.10.3

@n-riesco
Copy link
Owner

n-riesco commented Jun 8, 2015

It works from within Jupyter.
I will check whether I can reproduce the issue from within Hydrogen.
In the meantime could you check it works from within the Node.js REPL. Note that from within the REPL underscore _ is a special character in the Node.js REPL. See the documentation here.

$ npm install lodash
lodash@3.9.3 node_modules/lodash
$ node
> require("lodash")
{ [Function: lodash]
  support: { dom: false },
  templateSettings: 
   { escape: /<%-([\s\S]+?)%>/g,
     evaluate: /<%([\s\S]+?)%>/g,
     interpolate: /<%=([\s\S]+?)%>/g,
     variable: '',
     imports: { _: [Circular] } },
  after: [Function: after],
  ary: [Function: ary],
  assign: [Function],
  at: [Function],
  before: [Function: before],
  bind: { [Function] placeholder: [Circular] },
  bindAll: [Function],
  bindKey: { [Function] placeholder: [Circular] },
  callback: [Function: callback],
  chain: [Function: chain],
  chunk: [Function: chunk],
  compact: [Function: compact],
  constant: [Function: constant],
  countBy: [Function],
  create: [Function: create],
  curry: { [Function: curryFunc] placeholder: [Circular] },
  curryRight: { [Function: curryFunc] placeholder: [Circular] },
  debounce: [Function: debounce],
  defaults: [Function],
  defer: [Function],
  delay: [Function],
  difference: [Function],
  drop: [Function: drop],
  dropRight: [Function: dropRight],
  dropRightWhile: [Function: dropRightWhile],
  dropWhile: [Function: dropWhile],
  fill: [Function: fill],
  filter: [Function: filter],
  flatten: [Function: flatten],
  flattenDeep: [Function: flattenDeep],
  flow: [Function],
  flowRight: [Function],
  forEach: [Function],
  forEachRight: [Function],
  forIn: [Function],
  forInRight: [Function],
  forOwn: [Function],
  forOwnRight: [Function],
  functions: [Function: functions],
  groupBy: [Function],
  indexBy: [Function],
  initial: [Function: initial],
  intersection: [Function],
  invert: [Function: invert],
  invoke: [Function],
  keys: [Function],
  keysIn: [Function: keysIn],
  map: [Function: map],
  mapKeys: [Function],
  mapValues: [Function],
  matches: [Function: matches],
  matchesProperty: [Function: matchesProperty],
  memoize: { [Function: memoize] Cache: [Function: MapCache] },
  merge: [Function],
  method: [Function],
  methodOf: [Function],
  mixin: [Function: mixin],
  negate: [Function: negate],
  omit: [Function],
  once: [Function: once],
  pairs: [Function: pairs],
  partial: { [Function] placeholder: [Circular] },
  partialRight: { [Function] placeholder: [Circular] },
  partition: [Function],
  pick: [Function],
  pluck: [Function: pluck],
  property: [Function: property],
  propertyOf: [Function: propertyOf],
  pull: [Function: pull],
  pullAt: [Function],
  range: [Function: range],
  rearg: [Function],
  reject: [Function: reject],
  remove: [Function: remove],
  rest: [Function: rest],
  restParam: [Function: restParam],
  set: [Function: set],
  shuffle: [Function: shuffle],
  slice: [Function: slice],
  sortBy: [Function: sortBy],
  sortByAll: [Function],
  sortByOrder: [Function: sortByOrder],
  spread: [Function: spread],
  take: [Function: take],
  takeRight: [Function: takeRight],
  takeRightWhile: [Function: takeRightWhile],
  takeWhile: [Function: takeWhile],
  tap: [Function: tap],
  throttle: [Function: throttle],
  thru: [Function: thru],
  times: [Function: times],
  toArray: [Function: toArray],
  toPlainObject: [Function: toPlainObject],
  transform: [Function: transform],
  union: [Function],
  uniq: [Function: uniq],
  unzip: [Function: unzip],
  unzipWith: [Function: unzipWith],
  values: [Function: values],
  valuesIn: [Function: valuesIn],
  where: [Function: where],
  without: [Function],
  wrap: [Function: wrap],
  xor: [Function: xor],
  zip: [Function],
  zipObject: [Function: zipObject],
  zipWith: [Function],
  backflow: [Function],
  collect: [Function: map],
  compose: [Function],
  each: [Function],
  eachRight: [Function],
  extend: [Function],
  iteratee: [Function: callback],
  methods: [Function: functions],
  object: [Function: zipObject],
  select: [Function: filter],
  tail: [Function: rest],
  unique: [Function: uniq],
  add: [Function: add],
  attempt: [Function],
  camelCase: [Function],
  capitalize: [Function: capitalize],
  clone: [Function: clone],
  cloneDeep: [Function: cloneDeep],
  deburr: [Function: deburr],
  endsWith: [Function: endsWith],
  escape: [Function: escape],
  escapeRegExp: [Function: escapeRegExp],
  every: [Function: every],
  find: [Function],
  findIndex: [Function],
  findKey: [Function],
  findLast: [Function],
  findLastIndex: [Function],
  findLastKey: [Function],
  findWhere: [Function: findWhere],
  first: [Function: first],
  get: [Function: get],
  gt: [Function: gt],
  gte: [Function: gte],
  has: [Function: has],
  identity: [Function: identity],
  includes: [Function: includes],
  indexOf: [Function: indexOf],
  inRange: [Function: inRange],
  isArguments: [Function: isArguments],
  isArray: [Function: isArray],
  isBoolean: [Function: isBoolean],
  isDate: [Function: isDate],
  isElement: [Function],
  isEmpty: [Function: isEmpty],
  isEqual: [Function: isEqual],
  isError: [Function: isError],
  isFinite: [Function: isFinite],
  isFunction: [Function: baseIsFunction],
  isMatch: [Function: isMatch],
  isNaN: [Function: isNaN],
  isNative: [Function: isNative],
  isNull: [Function: isNull],
  isNumber: [Function: isNumber],
  isObject: [Function: isObject],
  isPlainObject: [Function],
  isRegExp: [Function: isRegExp],
  isString: [Function: isString],
  isTypedArray: [Function: isTypedArray],
  isUndefined: [Function: isUndefined],
  kebabCase: [Function],
  last: [Function: last],
  lastIndexOf: [Function: lastIndexOf],
  lt: [Function: lt],
  lte: [Function: lte],
  max: [Function],
  min: [Function],
  noConflict: [Function: noConflict],
  noop: [Function: noop],
  now: [Function: now],
  pad: [Function: pad],
  padLeft: [Function],
  padRight: [Function],
  parseInt: [Function],
  random: [Function: random],
  reduce: [Function],
  reduceRight: [Function],
  repeat: [Function: repeat],
  result: [Function: result],
  runInContext: [Function: runInContext],
  size: [Function: size],
  snakeCase: [Function],
  some: [Function: some],
  sortedIndex: [Function],
  sortedLastIndex: [Function],
  startCase: [Function],
  startsWith: [Function: startsWith],
  sum: [Function: sum],
  template: [Function: template],
  trim: [Function: trim],
  trimLeft: [Function: trimLeft],
  trimRight: [Function: trimRight],
  trunc: [Function: trunc],
  unescape: [Function: unescape],
  uniqueId: [Function: uniqueId],
  words: [Function: words],
  all: [Function: every],
  any: [Function: some],
  contains: [Function: includes],
  eq: [Function: isEqual],
  detect: [Function],
  foldl: [Function],
  foldr: [Function],
  head: [Function: first],
  include: [Function: includes],
  inject: [Function],
  sample: [Function: sample],
  VERSION: '3.9.3',
  _: [Circular] }
> _.first([1])
1
> 

@n-riesco
Copy link
Owner

n-riesco commented Jun 8, 2015

Hi Jakub,

I've just checked and it works for me on Hydrogen.

At this point, I'm more inclined to think this is an issue with the installation of lodash.

Please, could you check if the following works on your computer:

$ npm install ijavascript lodash
$ ijs --ijs-install-kernel
$ ipython console --kernel javascript
In [1]: var _ = require("lodash");
Out[1]: undefined

In [2]: _.first([1])
Out[2]: 1

@holyjak
Copy link
Author

holyjak commented Jun 8, 2015

Surprisingly, this works. What I did before and expected to work:

npm install -g ijavascript
cd myproject;
ijs
# Then go to http://localhost:8888/notebooks/notebook.ipynb - it will show the error
# (As you can also see in GitHub's version of the notebook linked above though
# there it is understandable since GH likely doesn't run npm install in the directory)

So the notebook that I access via the local web interface after running ijs still fails to load lodash while inside ipython console --kernel javascript it is loaded w/o problems.
What is the difference? Shouldn't the notebook work as well? See my demo project.

Thank you!

@holyjak
Copy link
Author

holyjak commented Jun 8, 2015

Sorry, it is now working in ijs as well. When I originally set up my example project I forgot to run npm install in it. I did run it now but initially it hasn't seemed to help while now it is ok.
Sorry for troubling you! I will look more into what could be my problem with Hydrogen.

@holyjak holyjak closed this as completed Jun 8, 2015
@holyjak
Copy link
Author

holyjak commented Jun 8, 2015

BTW Hydrogen now works for me as well with this example project.

@n-riesco
Copy link
Owner

n-riesco commented Jun 8, 2015

No worries! Thanks for letting me know.

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

2 participants