import { Head, Appear } from "mdx-deck"; import Logo from "./assets/images/logos/rdc-icon.svg"; export { default as theme } from "./theme"; import { CodeSurfer } from "mdx-deck-code-surfer"; import ultramin from "prism-react-renderer/themes/ultramin";
Ecosystem: The wide, wonderful, weird world of JavaScript
- Client's Browser receives JS as part of a webpage
- Node is a runtime to run JS outside of a browser
- Host and tool for JavaScript packages maintained by the community
The largest package manager in the world
npm init // creates a new Javascript project (package.json)
npm install [dependency name] // installs package into your project
npm install // installs all dependencies of your project
package.json
describes your project's dependenciesnpm install
looks them up, and downloads them locally!
Generated Files:
node_modules
is the folder where the dependencies livepackage-lock.json
is a description of installed packages
npm run [script name] // runs script from package.json
npm start // runs the "start" script from package.json
npm install [dep name] [dep name2] // installs multiple dependencies at once!
- Great ecosystem of build tools
- Easy package management!
<script>...</script>
- Bower +
<script>...</script>
- npm + Build step
If you really, really need jQuery:
<script
src="https://cdnjs.../3.4.0/jquery.min.js"
>
</script>
Don't
- Install a package (
npm install jquery
) - Import it in your project JS:
import $ from "jquery";
import
s aren't widely supported in browsers (this is changing)- There are tools to convert
import
s to:
And that all gets stuck in a <script>
!
Turns out, this is really hard by yourself.
- Handy tool:
create-react-app
npx create-react-app [folder of new project]