question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`--version` is not working as expected if installed via npm

See original GitHub issue

Issue

It’s using the package.json in the working directory…

Examples

Directory without package.json

elm-language-server -v
/home/user/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/node_modules/web-tree-sitte
var Module=void 0!==Module?Module:{};!function(e,t){"function"==typeof define&&define.amd?define([],t):
ule.hasOwnProperty(e)&&(t[e]=Module[e]);Module.arguments=[],Module.thisProgram="./this.program",Module.
a="function"==typeof importScripts,i="object"==typeof process&&"function"==typeof require&&!r&&!a,n=!r&
,l||(l=require("path")),e=l.normalize(e),n=o.readFileSync(e),t?n:n.toString()},Module.readBinary=functi
gv.length>1&&(Module.thisProgram=process.argv[1]

Error: ENOENT: no such file or directory, open '/home/user/dotfiles/package.json'
    at Object.openSync (fs.js:447:3)
    at Object.readFileSync (fs.js:349:35)
    at Function.module.exports.sync (/home/user/.npm-global/lib/node_modules/@elm-tooling/elm-langua
    at getVersion (/home/user/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/node_mod
    at Object.<anonymous> (/home/user/.npm-global/lib/node_modules/@elm-tooling/elm-language-server/
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19)))))

Directory with package.json

It shows the local version…

elm-language-server -v
1.0.0

Related code

https://github.com/elm-tooling/elm-language-server/blob/5a39e7159ecb710e13f2d04102dbbeb27d2b289f/src/index.ts#L18

Fixes

  • Make the typescript import (disallowed by current config) of package.json work and replace dependency
  • Copy current version into code or file in compile step
  • Look for other dependencies that actually work as expected

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
andys8commented, Oct 21, 2019

If we add more args and help, we should probably use a args parser library. Current implementation feels hacky.

1reaction
razzeeecommented, Oct 21, 2019

Forget about that windows log, I somehow ended up calling the old haskell version of the server…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error npm is known not to run on Node.js v10.24.1 and how to ...
Download and install the latest version of nodejs. · Open you terminal and verify you have the latest version using node -v ....
Read more >
Inconsistency between node versions of npm and yarn #812
The engine "node" is incompatible with this module. Expected version ">=4.5.0". If the current behavior is a bug, please provide the steps to ......
Read more >
Common errors | npm Docs
Some strange issues can be resolved by simply running npm cache clean and trying again. If you are having trouble with npm install...
Read more >
npm-install - npm Docs
Description. This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap...
Read more >
Webpack - npm
webpack. Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found