Hi all I have my own npm package where I want to make some updates and before publish I would like to test locally.
But when I try to launch my script I get this error:
{ RequestError: getaddrinfo ENOTFOUND function function:80
at ClientRequest.req.once.err (/Users/someUser/Sites/package-info/node_modules/got/index.js:73:21)
at ClientRequest.g (events.js:291:16)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1020:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
code: 'ENOTFOUND',
message: 'getaddrinfo ENOTFOUND function function:80',
host: 'function',
hostname: 'function',
method: 'HEAD',
path: '%20(scope)%20%7B%0A%09var%20rc%20=%20require(%27rc%27)(%27npm%27,%20%7Bregistry:%20%27https://registry.npmjs.org/%27%7D);%0A%09var%20url%20=%20rc[scope%20+%20%27:registry%27]%20%7C%7C%20rc.registry;%0A%09return%20url.slice(-1)%20===%20%27/%27%20?%20url%20:%20url%20+%20%27/%27;%0A%7Dpackage-info' }
This is my index.js
'use strict';
var got = require('got');
var registryUrl = require('registry-url');
var Promise = require('pinkie-promise');
module.exports = function (name) {
if (typeof name !== 'string') {
return Promise.reject(new Error('package name required'));
}
return got.head(registryUrl + name.toLowerCase())
.then(function (res) {
return {
'test': 'test'
};
})
.catch(function (err) {
if (err.statusCode === 404) {
err.message = 'Package doesn\'t exist';
}
throw err;
});
};
And this is my cli.js
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var info = require('./');
var argv = process.argv.slice(2);
var input = argv[0];
function help() {
console.log(pkg.description);
console.log('');
console.log('Usage');
console.log(' $ package-info <package-name>');
console.log('');
console.log('Example');
console.log(' $ package-info pageres');
}
if (!input || argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
info(input)
.then(version => console.log(version))
.catch(err => {
console.error(err);
process.exit(1);
});
To launch locally my package I use from command line terminal:
my-package-name another-package-name
How to solve this error?
via Alessandro Minoccheri
No comments:
Post a Comment