Sitelet https://github.com/coder/code-server/issues/5174
Skip to content

Can't install with NPM (Workaround: use yarn instead) #5174

Description

@U5B

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • OS: Ubuntu
  • code-server --version: 4.4.0
    Running on Raspberry Pi 4 on Ubuntu 20.10

Steps to Reproduce

  1. run command sudo npm i -g code-server
  2. error appears when installing

Expected

code-server should install and NPM should not log any errors.

Actual

NPM gives an installation error.

Logs

npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/code-server/node_modules/argon2
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.15.0 | linux | arm
npm ERR! gyp info find Python using Python version 3.9.7 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/code-server/node_modules/argon2/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.15.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.15.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.15.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/local/lib/node_modules/code-server/node_modules/argon2',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! node:internal/modules/cjs/loader:936
npm ERR!   throw err;
npm ERR!   ^
npm ERR! 
npm ERR! Error: Cannot find module 'node-addon-api'
npm ERR! Require stack:
npm ERR! - /usr/local/lib/node_modules/code-server/node_modules/argon2/[eval]
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
npm ERR!     at [eval]:1:1
npm ERR!     at Script.runInThisContext (node:vm:129:12)
npm ERR!     at Object.runInThisContext (node:vm:305:38)
npm ERR!     at node:internal/process/execution:76:19
npm ERR!     at [eval]-wrapper:6:22
npm ERR!     at evalScript (node:internal/process/execution:75:60) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/usr/local/lib/node_modules/code-server/node_modules/argon2/[eval]'
npm ERR!   ]
npm ERR! }
npm ERR! gyp: Call to 'node -p "require('node-addon-api').include"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.13.0-1025-raspi
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/code-server/node_modules/argon2
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-06T21_41_52_086Z-debug-0.log

Screenshot/Video

No response

Does this issue happen in VS Code?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

Node Version: 16.15.0
NPM Version: 8.5.5
Running on a Raspberry Pi 4

Activity

  1. added
    bugSomething isn't working
    triageThis issue needs to be triaged by a maintainer
    on May 6, 2022
  2. U5B commented on May 6, 2022

    @U5B
    Author

    Installing yarn via npm install -g yarn and running sudo yarn global add code-server works however.

  3. jsjoeio commented on May 6, 2022

    @jsjoeio
    Contributor

    Interesting! I wonder why it works with yarn and not npm? Any ideas by chance @edvincent ?

  4. edvincent commented on May 9, 2022

    @edvincent
    Contributor

    I wonder why it works with yarn and not npm

    Because yarn doesn't respect ANY lockfiles when installing something globally (and anyway when running yarn publish, files like yarn.lock get deleted.

    Why it started failing now is likely because of the Node 14 => 16 transition... And indirectly the fact that I completely forgot to finish #5071... Which partly was because we were trying to find a "perfect" solution...

    I won't get around today, but let me update that PR by tomorrow with something to unblock, and maybe we can iterate through a better solution over PRs.

    Maybe we should rename this current issue "Can't install with NPM" (with a workaround being "Use yarn") until then?

    And a new PR linked to this issue would likely be part of the CI workflows doing an "npm install ARTIFACT" - to catch these?

  5. changed the title [-][Bug]: Could not find module 'node-addon-api' when running 'sudo npm i -g code-server'[/-] [+]Can't install with NPM (Workaround: use yarn instead)[/+] on May 9, 2022
  6. jsjoeio commented on May 9, 2022

    @jsjoeio
    Contributor

    Ah right @edvincent! Haha no worries at all. There has certainly been a lot of back and forth. I'll keep an eye on your PR.

  7. whschultz commented on May 12, 2022

    @whschultz

    I was able to get it to build on a Raspberry Pi 4 using the latest npm@^6. I had problems with npm@8.

  8. Atralupus commented on Jun 23, 2022

    @Atralupus

    I had the same problem, but I solved it using yarn too.

    https://coder.com/docs/code-server/latest/install#raspberry-pi
    Would you link this issue to the document above?🙏

  9. jsjoeio commented on Jun 23, 2022

    @jsjoeio
    Contributor

    I think #5071 should resolve this.

    PRs welcome to make any doc changes 🙏🏼

  10. added 2 commits that reference this issue on Jun 24, 2022
  11. Atralupus commented on Jun 24, 2022

    @Atralupus

    I think #5071 should resolve this.

    PRs welcome to make any doc changes 🙏🏼

    Thank you and I did request the PR

  12. added a commit that references this issue on Aug 1, 2022
  13. edvincent commented on Aug 20, 2022

    @edvincent
    Contributor

    Confirmed locally with the artifacts from #5071 that code-server can be installed (again) with npm.

    Currently it will be in the same state as when using yarn (due to npm/cli#5325): it will use whatever versions of dependencies are the latest at install time.

  14. removed
    triageThis issue needs to be triaged by a maintainer
    on Aug 22, 2022
  15. added this to the August 2022 milestone on Aug 22, 2022
  16. edvincent commented on Aug 22, 2022

    @edvincent
    Contributor

    Seems to install all good as expected now :D

    ubuntu@ip-172-26-6-151:~$ npm install -g --unsafe-perm code-server@4.6.0-beta-90f603549adbcbb608041fda2138265523ff0353
    
    added 211 packages, and audited 212 packages in 1m
    
    12 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    
  17. edvincent commented on Aug 22, 2022

    @edvincent
    Contributor

    And as a good news, the bug from npm/cli#5325 doesn't seem to affect remote installs (I obviously was only testing with local packages), so the npm install is fully deterministic.

    argon2 was the thing I kept looking at - which installed correctly with argon2@0.28.4 rather than the latest argon2@ 0.28.7 (which I had trouble with when installing locally).

  18. jsjoeio commented on Aug 22, 2022

    @jsjoeio
    Contributor

    Seems to install all good as expected now :D

    woohoo! @edvincent should we close this now?

  19. jsjoeio commented on Aug 23, 2022

    @jsjoeio
    Contributor

    Closing this since #5071 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions