【问题标题】:npm ERR! missing script: (insert anything here) on Vue.js app after moving foldernpm 错误!缺少脚本:(在此处插入任何内容)移动文件夹后在 Vue.js 应用程序上
【发布时间】:2021-03-04 16:02:28
【问题描述】:

我正在将一个 Vue.js 应用程序移动到一个新的存储库中,并从它的旧主机中提取它。

此时我已经将应用程序从一个文件夹复制到另一个文件夹,但它不会构建。它在第一个文件夹中构建良好,但在第二个文件夹中构建良好。

只要我输入npm run build / npm run build-app-only(或其他任何内容)我就会得到这个......

npm ERR! missing script: vue-cli-service

node-sass is not recognised as an internal or external command

这是我的 package.json 的脚本部分......

"scripts": {
    "serve-vstudio": "npm run messaging-css && vue-cli-service serve",
    "serve": "npm run messaging-css && vue-cli-service serve --port 8080",
    "build": "npm run messaging-css && vue-cli-service build",
    "build-app-only": "npm run vue-cli-service build",
    "build-debug": "npm run messaging-css && vue-cli-service build --mode staging",
    "test": "vue-cli-service test:unit \"\\.*\\.spec\\.js$\" --testPathIgnorePatterns=\"\\long/.*\\.spec\\.js$\"",
    "test-all": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" vue-cli-service test:unit \"\\.*\\.spec\\.js$\"",
    "test-long": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" vue-cli-service test:unit \"\\long/.*\\.spec\\.js$\"",
    "test-ci": "vue-cli-service test:unit \"\\.*\\.spec\\.js$\" --testPathIgnorePatterns=\"\\long/.*\\.spec\\.js$\"",
    "test-clear": "jest --clearCache",
    "test-watch": "vue-cli-service test:unit \"\\.*\\.spec\\.js$\" --testPathIgnorePatterns=\"\\long/.*\\.spec\\.js$\" --watch",
    "test-watch-all": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" vue-cli-service test:unit \"\\.*\\.spec\\.js$\" --watch",
    "test-watch-long": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" vue-cli-service test:unit \"\\long/.*\\.spec\\.js$\" --watch",
    "lint": "vue-cli-service lint",
    "dev": "vue-cli-service serve",
    "test:unit": "vue-cli-service test:unit",
    "view-cfg": "vue inspect > standard.config.js",
    "watch": "vue-cli-service build --mode development --watch",
    "messaging-css-ecofurb": "node-sass src/scss/schemes/messaging/ecofurb.scss -o public/schemes/ecofurb/css --output-style compressed & node-sass src/scss/schemes/messaging/ecofurb.scss -o ../plan-builder/schemes/ecofurb/css --output-style compressed",
    "messaging-css-oxfordshire": "node-sass src/scss/schemes/messaging/oxfordshire.scss -o public/schemes/oxfordshire/css --output-style compressed && node-sass src/scss/schemes/messaging/oxfordshire.scss -o ../plan-builder/schemes/oxfordshire/css --output-style compressed",
    "messaging-css-parity": "node-sass src/scss/schemes/messaging/parity.scss -o public/schemes/parity/css --output-style compressed && node-sass src/scss/schemes/messaging/parity.scss -o ../plan-builder/schemes/parity/css --output-style compressed",
    "messaging-css-radbot": "node-sass src/scss/schemes/messaging/radbot.scss -o public/schemes/radbot/css --output-style compressed & node-sass src/scss/schemes/messaging/radbot.scss -o ../plan-builder/schemes/radbot/css --output-style compressed",
    "messaging-css-warmersussex": "node-sass src/scss/schemes/messaging/warmersussex.scss -o public/schemes/warmersussex/css --output-style compressed && node-sass src/scss/schemes/messaging/warmersussex.scss -o ../plan-builder/schemes/warmersussex/css --output-style compressed",
    "messaging-css": "npm run messaging-css-ecofurb && npm run messaging-css-oxfordshire && npm run messaging-css-parity && npm run messaging-css-radbot && npm run messaging-css-warmersussex"
  },
,
  "dependencies": {
    "ajv": "^5.0.0",
    "arg-guard": "^1.0.3",
    "axios": "^0.18.0",
    "breakpoint-sass": "^2.7.1",
    "core-js": "^2.6.5",
    "delay": "^4.3.0",
    "localforage": "^1.7.3",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "onload-function-stack": "^1.2.0",
    "susy": "^3.0.5",
    "uri-path-manager": "^1.0.4",
    "uuid": "^3.3.2",
    "vee-validate": "^2.1.3",
    "vue": "2.6.7",
    "vue-analytics": "^5.17.2",
    "vue-recaptcha": "^1.1.1",
    "vue-router": "3.0.1",
    "vuedraggable": "^2.20.0",
    "vuex": "^3.0.1",
    "window-wrapper": "^1.2.0"
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.7.2",
    "@vue/cli-plugin-babel": "^3.2.0",
    "@vue/cli-plugin-eslint": "^3.2.0",
    "@vue/cli-plugin-unit-jest": "^3.10.0",
    "@vue/cli-service": "^3.5.2",
    "@vue/eslint-config-airbnb": "^4.0.0",
    "@vue/server-test-utils": "1.0.0-beta.29",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "browserslist": "^4.12.0",
    "caniuse-lite": "^1.0.30001059",
    "cheerio": "^1.0.0-rc.3",
    "cross-env": "^7.0.2",
    "eslint": "^5.8.0",
    "eslint-config-prettier": "^3.3.0",
    "eslint-plugin-vue": "^5.0.0-0",
    "flush-promises": "^1.0.2",
    "happy-dom": "^0.14.1",
    "imagemin-webpack-plugin": "^2.4.2",
    "jest-junit-reporter": "^1.1.0",
    "lint-staged": "^7.2.2",
    "node-sass": "^4.10.0",
    "normalize-scss": "^7.0.1",
    "postcss-import": "^12.0.1",
    "postcss-url": "^8.0.0",
    "sass-loader": "^7.0.1",
    "vue-server-renderer": "2.6.7",
    "vue-template-compiler": "2.6.7"
  }

我从 package.json 所在的根文件夹运行。

我已尝试在不同的文件夹中制作另一个副本(也会中断)。

我尝试再次手动运行npm i(即使我复制了所有文件)。

我已经搜索了互联网,但所有关于此的解决方案似乎都围绕着未找到自定义脚本的脚本,但事实并非如此 - 我定义的脚本被发现很好,但脚本本身的调用却没有'搬家后似乎不再工作了。

【问题讨论】:

  • 如果删除node_modules,重新安装依赖项,然后重新运行命令会怎样?
  • 看来你的 vue-cli bin 已经附加到那个目录了,你可以在终端上运行 vue-cli-service 命令吗?正如文档所说:在 Vue CLI 项目中,@vue/cli-service 安装了一个名为 vue-cli-service 的二进制文件。您可以在 npm 脚本中以 vue-cli-service 的形式直接访问二进制文件,或者从终端以 ./node_modules/.bin/vue-cli-service 的形式访问该二进制文件。你的项目@vue/cli-service 有这种依赖关系吗?检查它是否在您在node_modules中创建的新文件夹中
  • @WesleyGuirra 或简单的npx vue-cli-service(它会首先查看node_modules
  • 是的,它将从node_modules 运行,但依赖项需要在 npm install 命令之前在 package.json 中列出。
  • 所有依赖项都已列出并存在且正确 - 为了简洁起见,我将它们排除在外,但会添加

标签: vue.js npm


【解决方案1】:

这不是关于scripts 部分,而是关于dependencies

全局安装,如图here:

npm install -g @vue/cli
# OR
yarn global add @vue/cli

如果还是不行,添加开发依赖:

npm i @vue/cli-service -D
# OR 
yarn add @vue/cli-service -D

【讨论】:

  • 这些都已安装并列出 - 在上面更新以显示。
  • @KeithJackson 尝试完整路径./node_modules/.bin/vue-cli-service
  • 这不是具体的 - 每件事都没有运行 - 'vue-cli-service'、'jest'、'node-sass' - 他们都莫名其妙地无法正常工作不同的根文件夹。我最好的猜测是某个地方的配置文件损坏了,或者当文件进入线束项目时被删除了。
  • 据我了解,您完全重新安装了模块,所以一切都应该正常工作,主文件package.jsonpackage.lock.json 存储版本 - 这两个文件已经足够了。如果你把它放在 github 上尝试克隆。
猜你喜欢
  • 2021-10-23
  • 2016-06-27
  • 1970-01-01
  • 2018-05-24
  • 1970-01-01
  • 2019-12-28
  • 2018-09-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多