purescript-contrib / governance

Guidelines and resources for the PureScript Contributors organization
15 stars 3 forks source link

Cannot build `updater` tool. #4

Closed JordanMartinez closed 4 years ago

JordanMartinez commented 4 years ago

While following the instructions for compiling the updater tool, I got stuck here:

  1. Ran nix-shell
  2. Ran npm run build
  3. Got this error: sh: ncc: command not found:
    
    [nix-shell:~/Programming/Git Projects/purescript-contrib-governance/updater]$ npm run build

contrib-updater@ build /home/jordan/Programming/Git Projects/purescript-contrib-governance/updater spago bundle-module --to output/index.js && ncc build --minify --out bin index.js

[info] Installation complete. Src Lib All Warnings 0 0 0
Errors 0 0 0
[info] Build succeeded. [info] Bundling first... [info] Bundle succeeded and output file to output/index.js [info] Make module succeeded and output file to output/index.js sh: ncc: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! contrib-updater@ build: spago bundle-module --to output/index.js && ncc build --minify --out bin index.js npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the contrib-updater@ build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in: npm ERR! /home/jordan/.npm/_logs/2020-08-27T20_42_15_055Z-debug.log

thomashoneyman commented 4 years ago

Good catch. The shell provides everything except the NPM dependencies — ncc, specifically, which might actually be in Nix and I haven’t checked — so you also need to run npm install.

JordanMartinez commented 4 years ago

Ok. Another issue to fix. I get an error when I run sudo npm link:

[nix-shell:~/Programming/Git Projects/purescript-contrib-governance/updater]$ sudo npm link
sudo npm link
sudo: npm: command not found

Turns out you have to exit nix-shell and then run npm link

thomashoneyman commented 4 years ago

Huh — that’s weird. I’m not exiting the shell and Node is included in the shell, which should also include npm automatically. You don’t have access to npm at all in the shell?

thomashoneyman commented 4 years ago

Reproduction from my system:

~/Desktop/governance/updater (main) $ which node
/.../.nvm/versions/node/v12.0.0/bin/node

~/Desktop/governance/updater (main) $ which npm
/.../.nvm/versions/node/v12.0.0/bin/npm

~/Desktop/governance/updater (main) $ nix-shell

[nix-shell:~/.../governance/updater]$ which node
/nix/store/0j4i6dsqq4fvvm7z5zka62vi3xrfgzv6-nodejs-12.15.0/bin/node

[nix-shell:~/.../governance/updater]$ which npm
/nix/store/0j4i6dsqq4fvvm7z5zka62vi3xrfgzv6-nodejs-12.15.0/bin/npm

However, it's also acceptable to just run npm link outside the shell.

JordanMartinez commented 4 years ago

The issue arises when I use both sudo and npm in the same command. Running npm link causes a crash due to permissions issues, which made me run sudo npm link. However, running that will then output the above error as though npm doesn't exist when it clearly does.