Why NOT package.json?
package.json
brings in unnecessary complexity.If you do not think so, have a look at Go and Deno.
Everyday Use without package.json
Tell npm to not save package:
npm config set save false
Install development tools as global packages:
npm i -g typescript
npm install -g eslint
npm i -g @zeit/ncc
For temporal usage or test, use npx
:
npx cloc index.js
npx
can also be used to test different node versions:
npx -p node@13 node -v
Install dependencies as devDependencies:
npm i -D express
npm i -D @types/express
Use ncc to package runtime dependencies into a single JavaScript file:
# install dependencies according to resolved urls to tarballs in package-lock.json
@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock
ncc build index.js --minify # output file: dist/index.js
Then you can move the bundled index.js
file to any place where Node.js is installed,and run it with node index.js
without installing any npm modules.
Alternative to npm run
Just use plain old Makefile, e.g.
dist/index.js: index.js
@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock
ncc build index.js --minify
Top comments (0)