npm global installed path config

In order to fix Error: EACCES: permission denied, access '/usr/lib/node_modules', a solution will be set installed path non-root. Here’s how to set it. 1 2 mkdir ~/.npm-global npm config set prefix '~/.npm-global' This can see if config set properly 1 npm config list Output will be like this 1 2 3 4 5 6 7 8 9 10 11 12 ; cli configs metrics-registry = "https://registry.npmjs.org/" scope = "" user-agent = "npm/6....

October 18, 2021 · 1 min · 122 words · Wesley Chen

Name Export vs Default Export

Name Export Export 1 2 3 4 5 6 7 export const Hello = () => { return <h1>Hello</h1>; } export const Goodbye = () => { return <h1>Goodbye</h1>; } We can export multiple components from a single file. Import 1 2 3 4 import { Hello, Goodbye } from "./Greetings" // or import * as Greetings from "./Greetings" <Greetings.Hello /> Default Export Export 1 2 3 4 5 const Hello = () => { return <h1>Hello</h1>; } export default Hello; only export one component per file;...

October 15, 2021 · 1 min · 184 words · Wesley Chen

ReactJs Learning Note

React is component-based Create react component class. Use ReactDOM.render() refresh html ReactDOM.render(element, container[, callback]) JSX component lifecycle

October 13, 2021 · 1 min · 17 words · Wesley Chen

JavaScript Learning Note

JavaScript Note 5 type Undefined Null String Boolen Number Others r Object 3 way create Object Object literal 1 var a = { name:'Wesley', score: 100 }; new operator 1 var a = new Date Constructor function 1 2 3 4 5 function Student(name, score){ this.name = name this.score = score } var a = new Student('Wesley', 100); Primitive variable assignment makes a “copy” Object variable assignment pass the “reference” Function can be anonymous // recommended 1 var add = function(a, b) { return a + b; }; Return a function 1 2 3 4 5 6 7 var f = function(s) { return s?...

October 12, 2021 · 5 min · 887 words · Wesley Chen