Tag: nativescript

不能创build目录tns_modules

我在运行演示应用程序im Nativescript时遇到问题。 我运行: tns run ios 并有错误: 无法在设备上应用更改:DEVICE_ID。 错误是:处理node_modules失败。 错误:cp:无法创build目录“/ workspace / demo / platforms / ios / demo / app / tns_modules”:没有这样的文件或目录。 我究竟做错了什么?

无法将npm包安装到nativescript项目(..安装nativescript-nodeify之后)

我遇到了一个让我头痛几个小时的问题。 我正在开发一个本地环境中开发的移动应用程序。 由于我的应用程序需要解码JSON Web令牌的login目的,我试图安装npm jsonwebtoken包,似乎不兼容nativescript。 在google之后,我find了我通过安装的“nativescript-nodeify”插件 tns plugin add nativescript-nodeify 之后,一切似乎工作正常,但后来我试图安装另一个包,这给了我以下错误: npm ERR! code EINVALIDPACKAGENAME npm ERR! Invalid package name "nativescript-nodeify/node_modules/string_decoder": name can only contain URL-friendly characters npm ERR! A complete log of this run can be found in: npm ERR! /home/jonas/.npm/_logs/2017-10-06T16_24_33_241Z-debug.log 这是日志文件的内容: 0 info it worked if it ends with ok 1 verbose cli […]

抓取Api:无法从本地主机获取数据

我一直在尝试使用nativescript创build一个android应用程序。我使用获取模块从我的服务器获取响应。当我试图从httpbin.org/get获取响应时,它是可以的。但是当我试图获得响应从我的本地服务器,我得到networking请求失败。 错误。 发送到httpbin.org/get- return fetchModule.fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) { console.log(r); }, function (e) { console.log(e); }); 发送到本地主机:8000 / api- return fetchModule.fetch("http://localhost:8000/api").then(response => { return response.text(); }).then(function (r) { console.log(r); }, function (e) { console.log(e); }); 当我尝试通过请求模块得到localhost:8000 / api中纯node.js的响应时,它运行良好。但是现在,我不知道如何使用fetch模块来解决nativescript中的这个问题。

将JavaScript库导入NativeScript

我正在学习NativeScript。 我有一个基本的应用程序工作。 我现在正试图导入一个我以前用过的JavaScript库。 我正在导入库使用: npm install git://github.com/my-company/my-project.git –save 我已经确认包正在安装。 在我的视图模型中,然后添加以下内容: var MyLibrary = require('MyLibrary'); 这一行本身导致应用程序崩溃。 基本上,NativeScript似乎无法find它(或加载它)。 我看了一下,我可以看到“node_modules”目录下的“MyLibrary”目录。 目录结构如下所示: . node_modules MyLibrary dist MyLibrary.min.js src MyLibrary.js package.json MyLibrary.js文件如下所示: class MyLibrary { process(vals) { let result = 0; if (vals) { vals.forEach(function(val) { result = result + val; }); } return result; } } module.exports = MyLibrary; […]