我正在尝试使用打字稿创建一个新的 2.5 项目。
tns info 表示 NS 为 2.5.3,tns-core-modules 为 2.5.2。
tns 创建测试 --template tsc
当我编译时,我收到以下错误:
`
从 C:\Users\pc\nativescript\sd4\hooks\before-prepare\nativescript-dev-android-snapshot.js 执行准备前钩子从 C:\Users\pc\nativescript\sd4\hooks 执行准备前钩子\before-prepare\nativescript-dev-typescript.js 找到对等 TypeScript 2.2.2 app/app.ts(8,22):错误 TS2307:找不到模块“应用程序”。
app/bundle-config.ts(1,11): 错误 TS2304: 找不到名称“全局”。
app/bundle-config.ts(3,5): 错误 TS2304: 找不到名称 'require'。
app/bundle-config.ts(6,5): 错误 TS2304: 找不到名称“全局”。app/bundle-config.ts(6,46): 错误 TS2304: 找不到名称“需要”。
app/main-page.ts(8,22): 错误 TS2307: 找不到模块“ui/page”。
app/main-view-model.ts(23,18): 错误 TS2339: 类型“HelloWorldModel”上不存在属性“notifyPropertyChange”。
`
以下是使用旧模板和使用 NativeScript 2.5.x 创建项目的步骤
tns create test --template [email protected]
cd test
rm -rf hooks
rm -rf platforms
rm -rf node_modules
tns platform add [email protected]
tns plugin remove tns-core-modules
tns plugin add [email protected]
tns build android
这将使用 tns-core-modules 2.5.2 和 android 运行时 2.5.0 构建您的项目,最后您的 package.json 将如下所示
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.myAppMod25",
"tns-android": {
"version": "2.5.0"
}
},
"dependencies": {
"nativescript-theme-core": "~1.0.2",
"tns-core-modules": "2.5.2"
},
"devDependencies": {
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*",
"nativescript-dev-typescript": "~0.3.5",
"typescript": "~2.1.0"
}
}
请记住,第一步将为您的tsconfig.json和references.d.ts创建NativeScript 2.5.x所需的内容。您可以将此应用程序用作参考。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句