Markdown-preview cannot find module onig_scanner.node


#1

I was looking to enhance markdown-preview, working with atom packages for the first time. I was able to clone the original core package and link it, however on trying to twitch to it using Markdown Preview: Toggle command I get the following error
Uncaught Error: Cannot find module '../build/Release/onig_scanner.node'

Drilling down further into this, I get the following stack trace on running atom --test spec

[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
[85782:1223/144137:INFO:CONSOLE(94)] "Error: Cannot find module '../build/Release/onig_scanner.node'
  at Module._resolveFilename (module.js:455:15)
  at Module._resolveFilename (/Applications/Atom.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
  at Function.Module._resolveFilename (/Applications/Atom.app/Contents/Resources/app.asar/src/module-cache.js:383:52)
  at Function.Module._load (module.js:403:25)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/oniguruma/lib/oniguruma.js:4:17)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/oniguruma/lib/oniguruma.js:69:4)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/grammar.js:10:16)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/grammar.js:365:4)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/grammar-registry.js:12:13)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/grammar-registry.js:261:4)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/first-mate.js:4:22)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/first-mate/lib/first-mate.js:8:4)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/highlights/lib/highlights.js:14:21)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/node_modules/highlights/lib/highlights.js:420:4)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/lib/renderer.coffee:5:14)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/lib/renderer.coffee:1:1)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/lib/markdown-preview-view.coffee:7:12)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/lib/markdown-preview-view.coffee:1:1)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/spec/markdown-preview-spec.coffee:5:23)
  at Object.<anonymous> (/Users/divyendusingh/Documents/projects/markdown-preview/spec/markdown-preview-spec.coffee:1:1)
  at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:103:30)
  at Object.value [as .coffee] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:201:21)
  at Module.load (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:432:12)
  at Function.Module._load (module.js:424:3)
  at Module.require (module.js:483:17)
  at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
  at requireSpecs (/Applications/Atom.app/Contents/Resources/app.asar/spec/jasmine-test-runner.js:94:9)
  at module.exports (/Applications/Atom.app/Contents/Resources/app.asar/spec/jasmine-test-runner.js:47:7)
  at module.exports (/Applications/Atom.app/Contents/Resources/app.asar/src/initialize-test-window.js:78:17)
  at setupWindow (file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js:81:12)
  at window.onload (file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js:41:9)
", source: /Applications/Atom.app/Contents/Resources/app.asar/src/initialize-test-window.js (94)

I could not find any instructions in the original repo to create the build folder. Any help on this issue ?


#2

It sounds like you didn’t run apm install after cloning the repo, so you don’t have any dependencies (like oniguruma) installed.


#3

I have run apm install and I got successful response Installing modules âś“

The only thing I did differently was to use yarn in place of npm install initially.
Trying to remove node_modules and re-install through npm install


#4

Yes, using npm install after removing node_modules worked. Wonder why yarn did not work here. I have been aggressively using yarn as alias to npm and it has been working ever since.

Thanks for your answer.


#5

I can’t say why yarn isn’t working as expected. Atom packages are structured the same way that Node packages are. However, if it’s a build script thing, then maybe yarn falls down on handling grunt tasks. That’s just a guess, though.


#6

That is what I had thought but I don’t see any commands / scripts in the package.json file. Good that this is resolved though, if we can document the reason in the same thread, that would be great. Looking for reasons. Thanks for your reply :slight_smile:


#7

It’s the dependency, oniguruma. That’s what you were seeing as not having been built, like it’s supposed to be on install.


#8

Aha, got it! Didn’t realize that these commands work recursively into the packages.
Anyhow, the PR that I had intended is ready: https://github.com/atom/markdown-preview/pull/458

Thanks


#9

Atom packages have a similar structure to Node modules, but they are not Node modules. You shouldn’t use yarn or npm to install Atom packages, even when developing.


#10

It is recommended at places to use npm install followed by apm install. Is that the right way or just apm install will suffice ?


#11

The only time that is necessary is when you are developing Node modules for use with Atom (such as atom-keymap), not Atom packages. It is never recommended to use npm when developing Atom packages.


#12

Thanks @leedohm :slight_smile: