UNPKG

829 BJavaScriptView Raw
1#!/usr/bin/env node
2// This is a single-use bin to help windows discover the proper prefix for npm
3// without having to load all of npm first
4// It does not accept argv params
5
6const path = require('path')
7const Config = require('@npmcli/config')
8const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions')
9const config = new Config({
10 npmPath: path.dirname(__dirname),
11 // argv is explicitly not looked at since prefix is not something that can be changed via argv
12 argv: [],
13 definitions,
14 flatten,
15 shorthands,
16 excludeNpmCwd: false,
17})
18
19async function main () {
20 try {
21 await config.load()
22 // eslint-disable-next-line no-console
23 console.log(config.globalPrefix)
24 } catch (err) {
25 // eslint-disable-next-line no-console
26 console.error(err)
27 process.exit(1)
28 }
29}
30main()