As an Administrator, you can set the execution policy by typing this into your PowerShell window:
Set-ExecutionPolicy RemoteSigned
Senior Software Engineer
Set-ExecutionPolicy RemoteSigned
npm list --depth=0
npm list -g --depth=0
If you'd like to see all available (remote) versions for a particular module, then do:
npm view <module_name> versions
Note, versions is plural. This will give you the full listing of versions to choose from.
For latest remote version:
npm view <module_name> version
Note, version is singular.
To find out which packages need to be updated, you can use
npm outdated -g --depth=0
To update global packages, you can use
npm update -g <package>
To update all global packages, you can use:
npm update -g
exports
instead of just adding properties and methods to it like in the last example provided by Jed Watson in this thread. I would personally discourage this practice as this breaks the circular reference support of the CommonJS modules mechanism. It is then not supported by all implementations and Jed example should then be written this way (or a similar one) to provide a more universal module:exports.run = function() {
console.log("Hello World!");
}
var sayHello = require('./Test');
sayHello.run(); // "Hello World!"
Object.assign(exports, {
// Put all your public API here
sayhello() {
console.log("Hello World!");
}
});
const { sayHello } = require('./Test');
sayHello(); // "Hello World!"
var http = require('http');
var fs = require('fs');
var path = require('path');
http.createServer(function (request, response) {
console.log('request ', request.url);
var filePath = '.' + request.url;
if (filePath == './') {
filePath = './index.html';
}
var extname = String(path.extname(filePath)).toLowerCase();
var mimeTypes = {
'.html': 'text/html',
'.js': 'text/javascript',
'.css': 'text/css',
'.json': 'application/json',
'.png': 'image/png',
'.jpg': 'image/jpg',
'.gif': 'image/gif',
'.wav': 'audio/wav',
'.mp4': 'video/mp4',
'.woff': 'application/font-woff',
'.ttf': 'application/font-ttf',
'.eot': 'application/vnd.ms-fontobject',
'.otf': 'application/font-otf',
'.svg': 'application/image/svg+xml'
};
var contentType = mimeTypes[extname] || 'application/octet-stream';
fs.readFile(filePath, function(error, content) {
if (error) {
if(error.code == 'ENOENT'){
fs.readFile('./404.html', function(error, content) {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
});
}
else {
response.writeHead(500);
response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
response.end();
}
}
else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
}).listen(8080);
int index = myList.FindIndex(a => a.Prop == oProp);
If you don't want to use LINQ, then:
int index;
for (int i = 0; i < myList.Count; i++)
{
if (myList[i].Prop == oProp)
{
index = i;
break;
}
}