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?
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
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.
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
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).
Activity
U5B commented on May 6, 2022
Installing yarn via npm install -g yarn and running sudo yarn global add code-server works however.
jsjoeio commented on May 6, 2022
Interesting! I wonder why it works with yarn and not npm? Any ideas by chance @edvincent ?
edvincent commented on May 9, 2022
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?
jsjoeio commented on May 9, 2022
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.
whschultz commented on May 12, 2022
I was able to get it to build on a Raspberry Pi 4 using the latest npm@^6. I had problems with npm@8.
Atralupus commented on Jun 23, 2022
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?🙏
jsjoeio commented on Jun 23, 2022
I think #5071 should resolve this.
PRs welcome to make any doc changes 🙏🏼
Add coder#5174 comment on rsp install
Add coder#5174 comment on rsp install
Atralupus commented on Jun 24, 2022
Thank you and I did request the PR
Add #5174 comment on rsp install (#5294)
edvincent commented on Aug 20, 2022
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.
edvincent commented on Aug 22, 2022
Seems to install all good as expected now :D
edvincent commented on Aug 22, 2022
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).
jsjoeio commented on Aug 22, 2022
woohoo! @edvincent should we close this now?
jsjoeio commented on Aug 23, 2022
Closing this since #5071 was merged.