【发布时间】: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 中列出。 -
所有依赖项都已列出并存在且正确 - 为了简洁起见,我将它们排除在外,但会添加