How to use the warn function from npmlog
Find comprehensive JavaScript npmlog.warn code examples handpicked from public code repositorys.
npmlog.warn logs a warning message to the console using the npm logging utility.
64 65 66 67 68 69 70 71 72 73
break; case 'emitReady': globalOptions.emitReady = Boolean(options.emitReady); break; default: log.warn("setOptions", "Unrecognized option given to setOptions: " + key); break; } }); }
+ 3 other calls in file
121 122 123 124 125 126 127 128 129 130
* log.silly(prefix, message, ...) * log.verbose(prefix, message, ...) * log.info(prefix, message, ...) * log.http(prefix, message, ...) * log.warn(prefix, message, ...) * log.error(prefix, message, ...) Like `log.log(level, prefix, message, ...)`. In this way, each level is given a shorthand, so you can do `log.info(prefix, message)`.
+ 5 other calls in file
How does npmlog.warn work?
npmlog.warn() is a method provided by the npmlog package in Node.js that logs a warning message to the console and/or a log file with the "warn" level. When called, it prints a message to the console with the format: [levelPrefix][prefix] message where levelPrefix is the prefix for the logging level ("warn" in this case), prefix is the log prefix specified by the user (if any), and message is the message passed as an argument to the method. Additionally, the message is also written to a log file if configured to do so.
111 112 113 114 115 116 117 118 119 120
getPom: function(pomFilePath) { var pom = {}; // the JSON rep. of the main XML POM try { pom = XML.parse(fs.readFileSync(pomFilePath, "utf-8")); } catch (err) { log.warn( "", "The main POM file could not be parsed, or was not found, is this not a Maven project?" ); log.warn("", JSON.stringify(err, null, 2));
+ 87 other calls in file
GitHub: glitch-soc/mastodon
57 58 59 60 61 62 63 64 65 66
const parseJSON = (json, req) => { try { return JSON.parse(json); } catch (err) { if (req.accountId) { log.warn(req.requestId, `Error parsing message from user ${req.accountId}: ${err}`); } else { log.silly(req.requestId, `Error parsing message from ${req.remoteAddress}: ${err}`); } return null;
Ai Example
1 2 3
const log = require("npmlog"); log.warn("myPackage", "A warning message");
This will log a warning message with the prefix "myPackage" to the console. The message will have a yellow color to indicate that it's a warning.
GitHub: tanx/hoodiecrow
7 8 9 10 11 12 13 14 15 16
log.level = config.log.level; // Handle error conditions process.on('SIGTERM', function() { log.warn('exit', 'Exited on SIGTERM'); process.exit(0); }); process.on('SIGINT', function() {
+ 5 other calls in file
GitHub: yingziwu/mastodon
108 109 110 111 112 113 114 115 116 117 118 119
} }; const startMaster = () => { if (!process.env.SOCKET && process.env.PORT && isNaN(+process.env.PORT)) { log.warn('UNIX domain socket is now supported by using SOCKET. Please migrate from PORT hack.'); } log.warn(`Starting streaming API server master with ${numWorkers} workers`); };
+ 209 other calls in file
GitHub: mayaeh/mastodon
167 168 169 170 171 172 173 174 175 176
application_name: '', }; }; const startWorker = async (workerId) => { log.warn(`Starting worker ${workerId}`); const app = express(); app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');
+ 15 other calls in file
GitHub: punkeel/node
0 1 2 3 4 5 6 7 8 9
// module to set the appropriate log settings based on configs // returns a boolean to say whether we should enable color on // stdout or not. // // Also (and this is a really inexcusable kludge), we patch the // log.warn() method so that when we see a peerDep override // explanation from Arborist, we can replace the object with a // highly abbreviated explanation of what's being overridden. const log = require('npmlog') const { explain } = require('./explain-eresolve.js')
GitHub: Jokerfive7/-Duelyst-
140 141 142 143 144 145 146 147 148
// If the target is in a managed directory and is in a symlink, but was // not in our parent that usually means someone else installed a bin file // with the same name as one of our bin files. if (target.managed && target.symlink) { log.warn('gentlyRm', 'not removing', target.path, "as it wasn't installed by", parent.path) return cb() }
+ 4 other calls in file
124 125 126 127 128 129 130 131 132 133
if (!regCache[url]) regCache[url] = pkg var versions = Object.keys(pkg.versions) var invalidVersions = versions.filter(function (v) { return !semver.valid(v) }) if (invalidVersions.length > 0) { log.warn('pickVersion', 'The package %s has invalid semver-version(s): %s. This usually only happens for unofficial private registries. ' + 'You should delete or re-publish the invalid versions.', pkg.name, invalidVersions.join(', ')) } versions = versions.filter(function (v) { return semver.valid(v) })
+ 6 other calls in file
GitHub: Jokerfive7/-Duelyst-
60 61 62 63 64 65 66 67 68 69
unsafe = unsafe || npm.config.get('unsafe-perm') if ((wd.indexOf(npm.dir) !== 0 || _incorrectWorkingDirectory(wd, pkg)) && !unsafe && pkg.scripts[stage]) { log.warn('lifecycle', logid(pkg, stage), 'cannot run in wd', '%s %s (wd=%s)', pkg._id, pkg.scripts[stage], wd ) return cb() }
+ 4 other calls in file
GitHub: Jokerfive7/-Duelyst-
29 30 31 32 33 34 35 36 37 38
} initJson(dir, initFile, npm.config, noProgressTillDone(function (er, data) { log.resume() log.silly('package data', data) if (er && er.message === 'canceled') { log.warn('init', 'canceled') return cb(null, data) } log.info('init', 'written successfully') cb(er, data)
128 129 130 131 132 133 134 135 136 137
locale, data } ); } else { log.warn('Subscription', `Not sending email for list id:${list.id} because not send configuration is set.`); } } catch (err) { log.error('Subscription', err); }
GitHub: siuying/jxcore
167 168 169 170 171 172 173 174 175 176
log.silly('validateExistingRemote', from, 'remote.origin.url:', originURL) } if (stderr) stderr = stderr.trim() if (stderr || er) { log.warn('addRemoteGit', from, 'resetting remote', cachedRemote, 'because of error:', stderr || er) return resetRemote(from, cloneURL, treeish, cachedRemote, cb) } else if (cloneURL !== originURL) { log.warn( 'addRemoteGit',
+ 3 other calls in file
GitHub: mapbox/node-pre-gyp
145 146 147 148 149 150 151 152 153 154
// the user/developer with the info to debug why full_message = 'Pre-built binaries not found for ' + package_json.name + '@' + package_json.version; full_message += ' and ' + opts.runtime + '@' + (opts.target || process.versions.node) + ' (' + opts.node_abi + ' ABI, ' + opts.libc + ')'; full_message += fallback_message; log.warn('Tried to download(' + err.statusCode + '): ' + opts.hosted_tarball); log.warn(full_message); log.http(err.message); } else { // If we do not have a statusCode that means an unexpected error // happened and prevented an http response, so we output the exact error
+ 7 other calls in file
19 20 21 22 23 24 25 26 27 28
} var testling = file.get('testling'); if (typeof testling === 'object') { log.warn('testlingify', 'Found existing testling config in package.json and am not overwriting it'); log.warn('testlingify', 'If you want me to overwrite it, first remove it from the package.json'); return cb(); } file.set({ testling: config.testling });
+ 3 other calls in file
15 16 17 18 19 20 21 22 23 24
this.remote = true; this.mq = require('socket.io-client').connect(url); this.mq.on('connect', () => { }); this.mq.on('connect_error', () => { log.warn('Error connecting to message broker server @ ' + url); }); this.mq.on('msg', (data) => { this.emit('msg', data);
+ 11 other calls in file
GitHub: testem/testem
8 9 10 11 12 13 14 15 16 17
this.messages = []; this.valid = true; } function warn(message) { log.warn('', message); } function hasOldBrowserArgsFormat(args) { return Object.prototype.hasOwnProperty.call(args, 'mode') ||
GitHub: zonkyio/testem
52 53 54 55 56 57 58 59 60 61
if (path) { if (config.appMode === 'dev') { let devModeFileReporter = config.get('dev_mode_file_reporter'); if (!devModeFileReporter) { log.warn('You configured a `report_file`, you may want to configure the `dev_mode_file_reporter` as well. Using the `tap` logger now.'); devModeFileReporter = 'tap'; } this.reporters.push(setupReporter(devModeFileReporter, this.reportFile.outputStream, config, app)); } else {
12 13 14 15 16 17 18 19 20
// Fetch mailchimp data const lists = await mailchimpApi.lists.getAll() if (lists.length > 1) { log.warn(logGroup, `More than one mailchimp audience found. will select the first with id=${lists[0].id}`) } const list = await mailchimpApi.lists.getListMembers(lists[0].id)
+ 3 other calls in file
npmlog.verbose is the most popular function in npmlog (7425 examples)