环境上下文中的 'const' 初始值设定项必须是字符串或数字文字或文字枚举引用
A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference
刚刚将 Nativescript 升级到版本 7 并出现以下错误,不确定 nativescript 为何会抛出此错误。
这是我的 package.json:
"dependencies": {
"@angular/animations": "^10.2.4",
"@angular/common": "^10.2.4",
"@angular/compiler": "^10.2.4",
"@angular/core": "^10.2.4",
"@angular/forms": "^10.2.4",
"@angular/platform-browser": "^10.2.4",
"@angular/platform-browser-dynamic": "^10.2.4",
"@angular/router": "^10.2.4",
"@nativescript/angular": "^10.1.7",
"@nativescript/core": "^7.1.0",
"@nativescript/webpack": "^4.0.0",
"@nstudio/nativescript-cardview": "^2.0.1",
"@types/jest": "^24.0.18",
"base-64": "^0.1.0",
"js-base64": "^2.5.2",
"nativescript-admob": "^4.0.0",
"nativescript-clipboard": "^2.0.0",
"nativescript-drop-down": "^5.0.6",
"nativescript-pdf-view": "^2.4.3",
"nativescript-permissions": "^1.3.11",
"nativescript-plugin-firebase": "^10.6.3",
"nativescript-theme-core": "^1.0.6",
"nativescript-toast": "^2.0.0",
"nativescript-ui-calendar": "^7.0.2",
"nativescript-ui-listview": "^9.0.4",
"nativescript-ui-sidedrawer": "^9.0.3",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.4.0",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular-devkit/schematics": "^10.2.1",
"@angular/cli": "^10.2.1",
"@angular/compiler-cli": "^10.2.4",
"@nativescript/android": "7.0.1",
"@nativescript/schematics": "^10.1.0",
"@nativescript/types": "^7.0.4",
"@ngtools/webpack": "^10.2.1",
"@schematics/angular": "^10.2.1",
"@schematics/update": "^0.11.4",
"node-sass": "^4.13.1",
"typescript": "^3.9.7"
},
我也试过打字稿 4,但会产生更多错误。
有人在下面遇到过这个问题:
确保您的tsconfig.json
包含
"skipLibCheck": true
如果您正在生成新项目但未在更新过程中添加,则默认情况下似乎会出现。添加它解决了我的问题,现在我可以毫无问题地编译应用程序。
下面是我的 tsconfig 文件的示例:
{
"compilerOptions": {
"module": "esnext",
"target": "es2017",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": [
"es2017",
"dom"
],
"baseUrl": ".",
"paths": {
"~/*": [
"src/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
这是一个 Nativescript 错误。该解决方案是在 5 天前实施的,但自 11 天以来没有新版本发布。在此期间,您可以自己修复它。这是解决方案:
https://github.com/NativeScript/NativeScript/pull/9136/commits/619fd49186f58d4d11d0554458af1210108c89d1
刚刚将 Nativescript 升级到版本 7 并出现以下错误,不确定 nativescript 为何会抛出此错误。
这是我的 package.json:
"dependencies": {
"@angular/animations": "^10.2.4",
"@angular/common": "^10.2.4",
"@angular/compiler": "^10.2.4",
"@angular/core": "^10.2.4",
"@angular/forms": "^10.2.4",
"@angular/platform-browser": "^10.2.4",
"@angular/platform-browser-dynamic": "^10.2.4",
"@angular/router": "^10.2.4",
"@nativescript/angular": "^10.1.7",
"@nativescript/core": "^7.1.0",
"@nativescript/webpack": "^4.0.0",
"@nstudio/nativescript-cardview": "^2.0.1",
"@types/jest": "^24.0.18",
"base-64": "^0.1.0",
"js-base64": "^2.5.2",
"nativescript-admob": "^4.0.0",
"nativescript-clipboard": "^2.0.0",
"nativescript-drop-down": "^5.0.6",
"nativescript-pdf-view": "^2.4.3",
"nativescript-permissions": "^1.3.11",
"nativescript-plugin-firebase": "^10.6.3",
"nativescript-theme-core": "^1.0.6",
"nativescript-toast": "^2.0.0",
"nativescript-ui-calendar": "^7.0.2",
"nativescript-ui-listview": "^9.0.4",
"nativescript-ui-sidedrawer": "^9.0.3",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.4.0",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular-devkit/schematics": "^10.2.1",
"@angular/cli": "^10.2.1",
"@angular/compiler-cli": "^10.2.4",
"@nativescript/android": "7.0.1",
"@nativescript/schematics": "^10.1.0",
"@nativescript/types": "^7.0.4",
"@ngtools/webpack": "^10.2.1",
"@schematics/angular": "^10.2.1",
"@schematics/update": "^0.11.4",
"node-sass": "^4.13.1",
"typescript": "^3.9.7"
},
我也试过打字稿 4,但会产生更多错误。
有人在下面遇到过这个问题:
确保您的tsconfig.json
包含
"skipLibCheck": true
如果您正在生成新项目但未在更新过程中添加,则默认情况下似乎会出现。添加它解决了我的问题,现在我可以毫无问题地编译应用程序。
下面是我的 tsconfig 文件的示例:
{
"compilerOptions": {
"module": "esnext",
"target": "es2017",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": [
"es2017",
"dom"
],
"baseUrl": ".",
"paths": {
"~/*": [
"src/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
这是一个 Nativescript 错误。该解决方案是在 5 天前实施的,但自 11 天以来没有新版本发布。在此期间,您可以自己修复它。这是解决方案: https://github.com/NativeScript/NativeScript/pull/9136/commits/619fd49186f58d4d11d0554458af1210108c89d1