node.js

npm link only dist folder

我与影子孤独终老i 提交于 2021-02-08 13:24:27
问题 Is there a way to restrict npm link to create the symlink only to point at ./dist ? I am struggling so far as I want to test my library (react component) locally before publishing. In my package.json I have included the main (entry point): "main": "./dist/index.js" But still when I run npm link it links to the parent folder which has node_modules and so on. This is causing problems cause now I have 2 react apps installed. I thought of a way to exclude node_modules but I couldn't even find a

npm link only dist folder

安稳与你 提交于 2021-02-08 13:21:58
问题 Is there a way to restrict npm link to create the symlink only to point at ./dist ? I am struggling so far as I want to test my library (react component) locally before publishing. In my package.json I have included the main (entry point): "main": "./dist/index.js" But still when I run npm link it links to the parent folder which has node_modules and so on. This is causing problems cause now I have 2 react apps installed. I thought of a way to exclude node_modules but I couldn't even find a

npm-force-resolutions not working when installing a new package

两盒软妹~` 提交于 2021-02-08 13:15:28
问题 I'm using the scripts section of the package.json to force resolutions: "preinstall": "npx npm-force-resolutions" in the resolutions section, I have entered graceful-fs with a specified version: "resolutions": { "graceful-fs": "^4.2.4", }, When i run npm i everything is installed correctly, the set versions are taken in to account. But later on when I install an additional module, e.g. npm i random-package , my set versions are being thrown away and I endup with graceful-fs@1.2.3 and other

Double request when chrome developer tools open

主宰稳场 提交于 2021-02-08 12:59:33
问题 I've an odd problem, i have a very simple node/expressjs app ( i have a much more complex one but this simple example shows the problem ). This app has three routes as shown here: var i = 0; app.route('/login') .get(function(req, res){ console.log('login', ++i); res.send('login'); }) app.route('/test') .get(function(req, res){ console.log('test', ++i); res.send('test'); }) app.route('/') .get(function(req, res){ console.log('index', ++i); res.send('index'); }) Pretty simple. Any time one of

mongodb remove document if array count zero after $pull in a single query

廉价感情. 提交于 2021-02-08 12:57:16
问题 I have a requirement where my comments schema looks like the following { "_id": 1, "comments": [ { "userId": "123", "comment": "nice" }, { "userId": "124", "comment": "super"} ] } I would like to pull the elements based on the userId field. I am doing the following query comments.update({},{$pull:{comments:{userId:"123"}}}) My requirement is that if the array length became zero after the pull operator I need to remove the entire document for some reason.Is there a away to do this in a single

Headers not showing in fetch response

和自甴很熟 提交于 2021-02-08 12:49:07
问题 I can see the header "x-auth-token" in Chrome DevTools. However, the header is not showing up in my fetch response. Please assist so I can use header data. I am using NodeJS as my backend API and ReactJS as my front-end. These are my files. NodeJS middleware - cors.js module.exports = function enableCorsSupport(app) { app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE"); res.header("Access

Avoid sending TLS_EMPTY_RENEGOTIATION_INFO_SCSV cipher in TLS Client Hello

旧城冷巷雨未停 提交于 2021-02-08 12:34:07
问题 Node.js sends the TLS_EMPTY_RENEGOTIATION_INFO_SCSV cipher by default to protect itself against the POODLE attack. I'm trying to avoid sending this cipher (even though this may pose a security risk) by overriding the TLS ciphers with a custom list of ciphers. However, Node.js keeps sending the TLS_EMPTY_RENEGOTIATION_INFO_SCSV cipher no matter what I do. I'm trying to deliberately avoid sending this cipher to mimic the TLS negotiation of Firefox/Chrome. Here's the code I use to modify and

error TS5014: Failed to parse file '': Unexpected token u in JSON at position 0. The terminal process terminated with exit code: 1

百般思念 提交于 2021-02-08 12:33:49
问题 I am receiving this error. error TS5014: Failed to parse file '/Users/Documents/tsconfig.json/tsconfig.json': Unexpected token u in JSON at position 0. The terminal process terminated with exit code: 1 My system setup: Visual Studio Code Version 1.14.1 Angular 2 node Version v8.0.0 tsc Version 2.4.1 package.json is as follows { "name": "angular-quickstart", "version": "1.0.0", "description": "QuickStart package.json from the documentation, supplemented with testing support", "scripts": {

Node: requiring module inside function?

人盡茶涼 提交于 2021-02-08 12:22:19
问题 I was browsing the source code for a command line utility in Node, and saw the following code. function help() { var colors = require('colors'); var package = require('../package'); .... .... } I had not seen require being used inside a function in this way before. I always assumed it was best practice to include it at the top of the file. This is the entry file for this program, and this function is only called in a specific case--but those packages are used elsewhere in the program. When I

Flip most of an svg image, but not the text within it

时光怂恿深爱的人放手 提交于 2021-02-08 12:17:58
问题 I have a big collection of svg images like this: <svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"> <g stroke="lightgray" stroke-dasharray="1,1" stroke-width="1" transform="scale(4, 4)"> <line x1="0" y1="0" x2="256" y2="256"></line> <line x1="256" y1="0" x2="0" y2="256"></line> <line x1="128" y1="0" x2="128" y2="256"></line> <line x1="0" y1="128" x2="256" y2="128"></line> </g> <g transform="scale(1, -1) translate(0, -900)"> <style> .stroke1 {fill: #BF0909;}