DEV Community

Zhangwuji
Zhangwuji

Posted on

study volta One

1.what is volta?
volta is a tool manager node,yarn, even some global npm binary package.
2.why do we use it?
1.when we used global npm binary package, e.g., tsc ,npm, vue-cli
webpack in a project, other developer could have different
version of global tool. this case may lead to hard-to-identify
bugs or inconsistencies in behavior
2.Unrelated project on your machine may depend on different global binary package that mean you have to manage and switch them when you switch project https://blog.volta.sh/2019/06/18/global-installs-done-right/
some expert advocate including the tool depends on your project in your dependence for example

{
  "name": "autojsts",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "volta": {
    "node": "14.17.0",
    "typescript": "^5.4.2",
    "npm": "7.24.0"
  },
  "dependencies": {
    "@autojs/types-pro8": "^8.8.0",
    "jquery": "^3.7.1"
  },
  "devDependencies": {
    "mocha": "^10.3.0",
    "typescript": "3.7"
  }
}

Enter fullscreen mode Exit fullscreen mode

typescript and mocha is including in package.json of your project
then using some script hash in package.json to facilitate running those tools。 hash also called hash table mean {} in javascript so script hash is "scripts": {
"start": "node server.js",
"test": "mocha"
}
;
But they don't work for these bootrap project like create-react-app.because they have own custom script hash to run;
volta solved both of these set of problems;
you can e.g. volta intall node@11.0 you can use node in terminal everywhere;

Top comments (0)