vue.js Yarn add raise error缺少要添加到项目中的包列表

68bkxrlz  于 2023-02-13  发布在  Vue.js
关注(0)|答案(6)|浏览(128)

重新安装Kubuntu 18后,我尝试运行我的@vue/cli 4.0.5/vuex 3应用程序,但出现错误:错误:缺少要添加到项目中的包列表

serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks$ node -v
v14.12.0
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks$ yarn -v
1.22.5
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks$ yarn add
yarn add v1.22.5
error Missing list of packages to add to your project.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks$ yarn upgrade
yarn upgrade v1.22.5
error No lockfile in this directory. Run `yarn install` to generate one.
info Visit https://yarnpkg.com/en/docs/cli/upgrade for documentation about this command.
serge@AtHome:/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks$ lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.5 LTS
4.15.0-118-generic
x86_64

我的包. json:

{
  "name": "ctasks",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:e2e": "vue-cli-service test:e2e",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@voerro/vue-tagsinput": "^2.2.0",
    "@vue/cli-plugin-babel": "^4.4.1",
    "axios": "^0.19.0",
    "core-js": "^3.3.2",
    "cypress-file-upload": "^3.5.3",
    "file-saver": "^2.0.2",
    "font-awesome": "^4.7.0",
    "idle-vue": "^2.0.5",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.27",
    "v-money": "^0.8.1",
    "vee-validate": "^3.1.0",
    "vue": "^2.6.10",
    "vue-avatar": "^2.1.8",
    "vue-context-menu": "^2.0.6",
    "vue-focus": "^2.1.0",
    "vue-head": "^2.2.0",
    "vue-js-modal": "^1.3.31",
    "vue-nav-tabs": "^0.5.7",
    "vue-notification": "^1.3.20",
    "vue-phone-number-input": "^1.1.9",
    "vue-router": "^3.1.3",
    "vue-select": "^3.2.0",
    "vue-simple-calendar": "^4.3.2",
    "vue-simple-suggest": "^1.10.1",
    "vue-slider-component": "^3.1.1",
    "vue-the-mask": "^0.11.1",
    "vue-upload-component": "^2.8.20",
    "vue-wysiwyg": "^1.7.2",
    "vue2-datepicker": "^3.3.0",
    "vue2-filters": "^0.8.0",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-e2e-cypress": "~4.2.0",
    "@vue/cli-plugin-eslint": "~4.2.0",
    "@vue/cli-plugin-router": "^4.0.0",
    "@vue/cli-plugin-vuex": "^4.0.0",
    "@vue/cli-service": "^4.0.0",
    "babel-eslint": "^10.0.3",
    "bootstrap": "^4.3.1",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.1.2",
    "faker": "^4.1.0",
    "jquery": "^3.4.1",
    "node-sass": "^4.12.0",
    "popper.js": "^1.16.0",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.10"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {
      "semi": [
        2,
        "never"
      ]
    }
  }
}

为什么会出错?如何修复?在重新安装我的Kubuntu之前,它工作正常。我错过了一些配置吗?我安装了lates节点,npm,yarn。谢谢!

xurqigkl

xurqigkl1#

阅读yarn add(https://classic.yarnpkg.com/en/docs/cli/add/)的文档时,您需要指定要安装的软件包
如果要添加程序包:

yarn add vue #same as npm install vue

如果您想从package.json加载所有依赖项

yarn #same as npm install

如果要从package.json运行自定义命令

yarn serve #same as npm run serve

你从yarn中看到的错误是因为你没有指定任何要安装的包,所以他告诉你:“请给予我您希望我在此项目中安装的软件包的名称”

3wabscal

3wabscal2#

当我尝试将npm install命令替换为yarn add时,我得到了同样的错误,但我没有注意到那里的--save-dev标志-yarn不支持该标志。
在我的例子中,简单地删除--save-dev标志就可以了,我猜更多的标志也会导致同样的错误
正如@Flafy提到的-也可以是-d,而不是yarn add命令上的-D

uplii1fm

uplii1fm3#

执行-D而不是--save-dev为我解决了这个问题。

mm9b1k5b

mm9b1k5b4#

1.删除"private": true,
1.保存您的package.json
1.运行npm install
1.再次将"private": true,放在您从中删除它的位置
1.省省吧...搞定

zvokhttg

zvokhttg5#

你需要告诉yarn要安装哪些包。
在您的例子中,您希望安装json中的所有包,因此您可以使用上面使用的相同命令:
>> yarn add
后跟UNIX单点命令(.),表示“在此执行上下文中”/“工作目录“,以获取:
>> yarn add .

7qhs6swi

7qhs6swi6#

来自yarn的错误信息是错误的,他们应该改变它。容易犯的错误是你用途:

yarn add -d babel-plugin-styled-components

而不是-D(用于开发依赖项),它应该是:

yarn add -D babel-plugin-styled-components

它会抛出这个错误,尽管插件列表是正确的。

相关问题