Giter VIP home page Giter VIP logo

go-npm's People

Contributors

jan-molak avatar sanathkr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-npm's Issues

New Maintainer: @leoafarias

Hi,

There are a few pending and open issues with this package especially in regards to security updates. I wanted to know if you would be open on letting me take over as some simple pull requests have been open for many months.

Please let me know I would be willing to maintain this going forward.

arm64 supported architecture

We recently had a user on a Raspberry PI try to install the railway.app cli but it failed to find the correct binary for their arch: railwayapp/cli#94

From their posted issue, the error is: Installation is not supported for this architecture: arm64

Upon first glance, it seems like their process.arch returns amd64, which is not listed in this map

go-npm/src/index.js

Lines 13 to 18 in ff6d922

// Mapping from Node's `process.arch` to Golang's `$GOARCH`
const ARCH_MAPPING = {
"ia32": "386",
"x64": "amd64",
"arm": "arm"
};

Thoughts on whether adding this would be okay? It looks like arm64 is valid for both Node and Go.
https://nodejs.org/api/process.html#process_process_arch
https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63#a-list-of-valid-goarch-values

How to generate binaries for all platforms?

This looks awesome. But how do I generate all those files? Is there an automatic tool that would generate binaries for all platforms and all architectures with a single command?

An updated fork

As this package has not received a lot of attention / maintenance lately, I've forked a fork of this adding some fixes and improvements. You can replace your package to use @gzuidhof/go-npm instead

The repo can be found here, here's the current list of changes:

    Support for zip and non-compressed binaries.
    Added support for arm64 architecture.
    Fix for use on Windows platform (the binary would get placed in the wrong place for consumers).
    Shipped as a bundle using esbuild, removing 70 packages of dependencies (including huge things like Babel). Now your users will only have to download one additional package (@guidhof/go-npm).

I'm happy to merge the changes into here one day, but I'm not holding my breath :)

judge the warning as error

there's in a situation, npm bin print some warning msg such as:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.  // stderr
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.  // stderr
C:\Users\john\AppData\Roaming\npm  //stdout

but your source code:

exec("npm bin -g", function(err, stdout, stderr) {

        let dir =  null;
        if (err || stderr || !stdout || stdout.length === 0)  {
            
            //   npm bin successfully print npm bin path with some warnings, but program goes to this branch.
            let env = process.env;
            if (env && env.npm_config_prefix) {
                dir = path.join(env.npm_config_prefix, "bin");
            }
        } else {
            dir = stdout.trim();
        }
        console.log(dir)
     

});

non-global install fails

In this example, I'm using @go-task/cli as an example. If this issue belongs elsewhere please let me know. Thanks!

Using npm, npm install exits with error. See log below.

Using pnpm, pnpm install command exits successfully, whereas it should exit with error because the binary does not get installed.

Repro: https://github.com/thenbe/repro-task-local

System info

$  nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.26, NixOS, 23.05 (Stoat), 23.05pre480050.1a411f23ba2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"nixos, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Log (npm install)
0 verbose cli /nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/bin/node /run/current-system/sw/bin/npm
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 0ms
5 timing config:load:file:/nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 0ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/home/nbe/projects/playground/task-repro/repro-task-non-monorepo/.npmrc Completed in 0ms
10 timing config:load:project Completed in 0ms
11 timing config:load:file:/home/nbe/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/etc/npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 0ms
16 timing config:load Completed in 3ms
17 timing npm:load:configload Completed in 3ms
18 timing npm:load:mkdirpcache Completed in 0ms
19 timing npm:load:mkdirplogs Completed in 0ms
20 verbose title npm install
21 verbose argv "install"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 1ms
24 timing npm:load:display Completed in 1ms
25 verbose logfile logs-max:10 dir:/home/nbe/.npm/_logs/2023-05-05T19_07_39_220Z-
26 verbose logfile /home/nbe/.npm/_logs/2023-05-05T19_07_39_220Z-debug-0.log
27 timing npm:load:logFile Completed in 2ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 8ms
31 timing arborist:ctor Completed in 0ms
32 silly logfile start cleaning logs, removing 2 files
33 silly logfile done cleaning log files
34 timing arborist:ctor Completed in 0ms
35 timing idealTree:init Completed in 6ms
36 timing idealTree:userRequests Completed in 0ms
37 silly idealTree buildDeps
38 silly fetch manifest @go-task/[email protected]
39 http fetch GET 200 https://registry.npmjs.org/@go-task%2fcli 2501ms (cache miss)
40 silly placeDep ROOT @go-task/[email protected] OK for: [email protected] want: 3.24.0
41 silly fetch manifest @go-task/go-npm@^0.1.17
42 http fetch GET 200 https://registry.npmjs.org/@go-task%2fgo-npm 322ms (cache miss)
43 timing idealTree:#root Completed in 2833ms
44 silly placeDep ROOT @go-task/[email protected] OK for: @go-task/[email protected] want: ^0.1.17
45 timing idealTree:node_modules/@go-task/cli Completed in 7ms
46 timing idealTree:node_modules/@go-task/go-npm Completed in 0ms
47 timing idealTree:buildDeps Completed in 2841ms
48 timing idealTree:fixDepFlags Completed in 1ms
49 timing idealTree Completed in 2848ms
50 timing reify:loadTrees Completed in 2849ms
51 timing reify:diffTrees Completed in 1ms
52 silly reify moves {}
53 timing reify:retireShallow Completed in 1ms
54 timing reify:createSparse Completed in 1ms
55 timing reify:loadBundles Completed in 0ms
56 silly audit bulk request { '@go-task/cli': [ '3.24.0' ], '@go-task/go-npm': [ '0.1.17' ] }
57 silly tarball no local data for @go-task/go-npm@https://registry.npmjs.org/@go-task/go-npm/-/go-npm-0.1.17.tgz. Extracting by manifest.
58 silly tarball no local data for @go-task/cli@https://registry.npmjs.org/@go-task/cli/-/cli-3.24.0.tgz. Extracting by manifest.
59 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 1181ms
60 timing auditReport:getReport Completed in 1183ms
61 silly audit report {}
62 timing auditReport:init Completed in 0ms
63 timing reify:audit Completed in 1185ms
64 http fetch GET 200 https://registry.npmjs.org/@go-task/cli/-/cli-3.24.0.tgz 1543ms (cache miss)
65 timing reifyNode:node_modules/@go-task/cli Completed in 1547ms
66 http fetch GET 200 https://registry.npmjs.org/@go-task/go-npm/-/go-npm-0.1.17.tgz 3328ms (cache miss)
67 timing reifyNode:node_modules/@go-task/go-npm Completed in 3331ms
68 timing reify:unpack Completed in 3331ms
69 timing reify:unretire Completed in 0ms
70 timing build:queue Completed in 1ms
71 timing build:link:node_modules/@go-task/go-npm Completed in 1ms
72 timing build:link Completed in 1ms
73 info run @go-task/[email protected] postinstall node_modules/@go-task/cli go-npm install
74 info run @go-task/[email protected] postinstall { code: 1, signal: null }
75 timing reify:rollback:createSparse Completed in 2ms
76 timing reify:rollback:retireShallow Completed in 0ms
77 timing command:install Completed in 8448ms
78 verbose stack Error: command failed
78 verbose stack     at ChildProcess.<anonymous> (/nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
78 verbose stack     at ChildProcess.emit (node:events:513:28)
78 verbose stack     at maybeClose (node:internal/child_process:1091:16)
78 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
79 verbose pkgid @go-task/[email protected]
80 verbose cwd /home/nbe/projects/playground/task-repro/repro-task-non-monorepo
81 verbose Linux 6.1.26
82 verbose node v18.16.0
83 verbose npm  v9.5.1
84 error code 1
85 error path /home/nbe/projects/playground/task-repro/repro-task-non-monorepo/node_modules/@go-task/cli
86 error command failed
87 error command sh -c go-npm install
88 error Downloading from URL: https://github.com/go-task/task/releases/download/v3.24.0/task_linux_amd64.tar.gz
89 error node:internal/fs/utils:347
89 error     throw err;
89 error     ^
89 error
89 error Error: EROFS: read-only file system, copyfile 'bin/task' -> '/nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/bin/task'
89 error     at copyFileSync (node:fs:2894:3)
89 error     at /home/nbe/projects/playground/task-repro/repro-task-non-monorepo/node_modules/@go-task/go-npm/bin/index.js:2:912957
89 error     at /home/nbe/projects/playground/task-repro/repro-task-non-monorepo/node_modules/@go-task/go-npm/bin/index.js:2:910247
89 error     at ChildProcess.exithandler (node:child_process:427:5)
89 error     at ChildProcess.emit (node:events:513:28)
89 error     at maybeClose (node:internal/child_process:1091:16)
89 error     at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
89 error   errno: -30,
89 error   syscall: 'copyfile',
89 error   code: 'EROFS',
89 error   path: 'bin/task',
89 error   dest: '/nix/store/liwmv8n976qnm2vv55nnqpwmjzfnswi7-nodejs-18.16.0/bin/task'
89 error }
89 error
89 error Node.js v18.16.0
90 verbose exit 1
91 timing npm Completed in 8465ms
92 verbose unfinished npm timer reify 1683313659237
93 verbose unfinished npm timer reify:build 1683313665426
94 verbose unfinished npm timer build 1683313665426
95 verbose unfinished npm timer build:deps 1683313665426
96 verbose unfinished npm timer build:run:postinstall 1683313665428
97 verbose unfinished npm timer build:run:postinstall:node_modules/@go-task/cli 1683313665428
98 verbose code 1
99 error A complete log of this run can be found in:
99 error     /home/nbe/.npm/_logs/2023-05-05T19_07_39_220Z-debug-0.log

FWIW, this used to work up until a month ago or so. I have an old repo on my system where the binary is correctly installed using pnpm. But re-running pnpm install in that repo does not install the binary correctly anymore. Many variables might have caused this to change, but the most likely could be node version or pnpm version.

Copying files in addition to the binary

Hi,
let me show you my usecase:
My go binary needs some configuration files to work with, so the file structure of a tar.gz archive from Goreleaser looks like this:

app_1.0.0_linux_amd64.tar.gz
├─data <-- directory, that I want to copy recursively. If possible to an appropriate directory
│ ├─data1.txt
│ ├─data2.json
│ ├─data3.yml
│ └─...
├─app <-- executable
└─LICENSE

Is this possible with this library? Do you have any recommendation?

Thanks in advance ...

Console log: permission denied

Run the command after using the npm installer on the mac platform, prompt: permission denied

ps: Because I encountered this problem (I am not familiar with mac), so I recorded it here to help new users later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.