当我从本地目录安装项目依赖项
npm install ../myDep
然后再次运行npm run serve
一切正常。
但是当我直接从仓库中安装此依赖项时
({npm install git+ssh://(...)/myDep.git
)(应以这种方式完成)
运行npm run serve
时出现错误:
Module parse failed: Unexpected token (14:9)
You may need an appropriate loader to handle this file type.
| }
|
> device = {
|
| info: () => {
这是文件的一部分,出现此错误:
export class MyDependencyClass {
constructor(args) {
(...)
}
device = {
info: () => {
return {};
},
(...)
}
(...)
}
此意外令牌是=
,仅当我从回购安装时才使用。
我该如何解决?
@edit package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"deploy": "./deploy.sh",
},
"dependencies": {
"core-js": "^3.3.2",
"myDep": "git+ssh://git@gitlab.com:pplaczek/myDep.git",
"markdown-it-vue": "^1.0.10",
"roboto-fontface": "*",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vue-the-mask": "^0.11.1",
"vuetify": "^2.1.0",
"vuex": "^3.0.1"
},
"devDependencies": {
"@mdi/font": "^3.9.97",
"@vue/cli-plugin-babel": "^4.0.0",
"@vue/cli-plugin-eslint": "^4.0.0",
"@vue/cli-service": "^4.0.0",
"@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.12.0",
"prettier": "^1.18.2",
"sass": "^1.19.0",
"sass-loader": "^8.0.0",
"vue-cli-plugin-vuetify": "^2.0.2",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.3.0"
}
}
vue.config.js
module.exports = {
transpileDependencies: ["vuetify"]
};
babel.config.js
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"]
};
答案 0 :(得分:0)
不能保证这会有所帮助,但是您可以尝试以下Babel配置:
module.exports = {
presets: [
[
'@vue/app',
{
exclude:
[
"@babel/plugin-transform-typeof-symbol",
'@babel/plugin-transform-regenerator',
],
modules: false
}
]
],
plugins:
[
"@babel/plugin-proposal-class-properties", // this seems to be the important one
]
}