Git Product home page Git Product logo

node-uwp's Introduction

node-uwp

Enables Universal Windows Platform (UWP) API access for Node.js (Chakra build) on Windows 10.

Example

const uwp = require('uwp');
const Windows = uwp.projectNamespace('Windows');

Windows.Storage.KnownFolders.documentsLibrary.createFileAsync(
  'sample.dat', Windows.Storage.CreationCollisionOption.replaceExisting)
  .done(
    function (file) {
      console.log('ok');
      uwp.close(); // all async operations are completed, release uwp
    },
    function (error) {
      console.error('error', error);
      uwp.close(); // all async operations are completed, release uwp
    }
);

Installation

Prerequisites

Run under Node.js (Chakra) command prompt:

npm install uwp

APIs

This package exports 2 functions.

projectNamespace(name)

Project a UWP namespace of given name.

  • Note: This function will keep Node process alive so that your app can continue to run and handle UWP async callbacks. You need to call close() when UWP usage is completed.

close()

Close all UWP handles used by this package. Call this when all UWP usage is completed.


Checkout our OSS effort with Node-ChakraCore. It supports the most recent version of node.js and will also be useful if you are on Windows 7 or Windows 8.1. Note: It does not support UWP.

node-uwp's People

Contributors

microsoft-github-policy-service[bot] avatar munyirik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-uwp's Issues

Any way to access MSApp?

MSDN page says:

The MSApp object and its members are supported only for Windows Store apps using JavaScript (WWAs). Like many WWA objects, the MSApp object only exists in the local context of a WWA (that is, an HTML document in a WWA loaded via the ms-appx URI scheme); otherwise, the object doesn’t exist (and consequently, none of its methods and properties are available).

It looks like node-uwp doesn't provide access to this MSApp object (at least direct .projectNamespace('MSApp') didn't work for me), and neither it's defined in WinJS that comes with Visual Studio template.

In that case, I'm wondering where is that object defined and whether there is any way to access it via node-uwp.

build: Wrong Windows SDK version

Reported by @grownseed in #11

Thanks @hgwood but still no luck... I've removed anything Node-related on my system, installed Node.js with Chakra, re-installed Visual Studio Community 2015 with Visual C++, Visual Studio Extensibility Tools Update 1, Windows 10 SDK, Universal Windows App Development Tools, rebooted, added GYP_MSVS_VERSION 2015 to my environment variables, npm config set python c:\python2.7\python.exe.

where node:

C:\Program Files\NodejsUwp\Console\node.exe

where npm:

C:\Program Files\NodejsUwp\Console\npm
C:\Program Files\NodejsUwp\Console\npm.cmd

where node-gyp:

C:\Program Files\NodejsUwp\Console\node_modules\npm\bin\node-gyp-bin\node-gyp
C:\Program Files\NodejsUwp\Console\node_modules\npm\bin\node-gyp-bin\node-gyp.cmd

Attempting to npm install uwp:

[...]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\prsht.h(607): error C2146: s
yntax error : missing ';' before identifier 'hdr' [C:\Users\Hadrien\Documents\D
ev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\prsht.h(607): error C4430: m
issing type specifier - int assumed. Note: C++ does not support default-int [C:
\Users\Hadrien\Documents\Dev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h(247): warning C419
3: #pragma warning(pop) : no matching '#pragma warning(push)' [C:\Users\Hadrien
\Documents\Dev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files\NodejsUwp\Console\sdk\deps\chakrashim\include\v8.h(65): fatal
error C1189: #error :  Wrong Windows SDK version [C:\Users\Hadrien\Documents\De
v\bb\node_modules\uwp\build\uwp.vcxproj]
[...]

Of particular note is Wrong Windows SDK version, it looks like it's pointing to the Windows 8.1 Kit, even though I do have the Windows 10 Kit available. I'm now stuck trying to figure out how to tell node-gyp to use the correct kit (if that's actually what's going on here...).

Node sources for version 5.0.0-0 do not exist.

The node.exe that comes with the Node.js Tools for Windows IoT 1.3 advertises 5.0.0-0 as a version (node --version). When I npm install uwp, node-gyp tries to download the sources for this version of node from https://nodejs.org/dist/v5.0.0-0/node-v5.0.0-0.tar.gz and logically fails, because this version it not an official version of Node.

$ npm i uwp
npm WARN engine [email protected]: wanted: {"node":">=0.8"} (current: {"node":"5.0.0-0","npm":"3.2.1"})
npm WARN install Couldn't install optional dependency: Unsupported

> [email protected] install C:\Dropbox\Coding\bb8\node_modules\uwp
> node-gyp rebuild


C:\Dropbox\Coding\bb8\node_modules\uwp>if not defined npm_config_node_gyp (node "C:\Users\Hugo Wood\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v5.0.0-0/node-v5.0.0-0.tar.gz
gyp ERR! stack    at Anonymous function (C:\Users\Hugo Wood\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\install.js:251:11)
gyp ERR! stack    at emitOne (events.js:82:7)
gyp ERR! stack    at emit (events.js:169:7)
gyp ERR! stack    at Request.prototype.onRequestResponse (C:\Users\Hugo Wood\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:992:5)
gyp ERR! stack    at emitOne (events.js:77:5)
gyp ERR! stack    at emit (events.js:169:7)
gyp ERR! stack    at parserOnIncomingClient (_http_client.js:421:3)
gyp ERR! stack    at parserOnHeadersComplete (_http_common.js:88:5)
gyp ERR! stack    at socketOnData (_http_client.js:311:3)
gyp ERR! stack    at emitOne (events.js:77:5)
gyp ERR! stack    at emit (events.js:169:7)
gyp ERR! stack    at readableAddChunk (_stream_readable.js:146:9)
gyp ERR! stack    at Readable.prototype.push (_stream_readable.js:110:3)
gyp ERR! stack    at onread (net.js:523:5)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files (x86)\\NodejsUwp\\Console\\node.exe" "C:\\Users\\Hugo Wood\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Dropbox\Coding\bb8\node_modules\uwp
gyp ERR! node -v v5.0.0-0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN EPACKAGEJSON [email protected] No description
npm WARN EPACKAGEJSON [email protected] No repository field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files (x86)\\NodejsUwp\\Console\\node.exe" "C:\\Users\\Hugo Wood\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "uwp"
npm ERR! node v5.0.0-0
npm ERR! npm  v3.2.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the uwp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls uwp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Dropbox\Coding\bb8\npm-debug.log

I'm not sure how I should proceed. I guess I could, as a workaround, copy the sources from Node v5 to ~/.node-gyp/5.0.0-0. I'll try that and let you know.

"Undeclared identifier" error when building with Visual Studio 2015

Hello,

I'm on Windows 10.0.15063 and when I try to rebuild the module with the following command:

node-gyp rebuild -- msvs_version=2015

I'm getting a bunch of "Undeclared identifier" errors in win_delay_load_hook.cc:

uwp

Any help would be greatly appreciated.

Thanks,
Anton

Unfamiliar code definition

Hey I am wondering why the sample code is like the following:

var uwp = require('uwp');
uwp.projectNamespace("Windows");
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync

instead of

var uwp = require('uwp');
var Windows = uwp.projectNamespace("Windows");
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync

I don't know if it's just me but variables being defined without a definition feels very uncomfortable. What is the reason for it working like this?

Error while installing the module

Pasting the console log -
C:\Users\hrishikesh\node_modules\uwp>npm install uwp
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\Program Files\NodejsUwp\Console\node.exe" "C:\Program Files\NodejsUwp\Console\node_modules\npm\bin\npm-cli.js" "install" "uwp"
npm ERR! node v7.0.0-pre8
npm ERR! npm v3.10.3

npm ERR! Reflect.apply: argument is not an array or array-like object
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\hrishikesh\node_modules\uwp\npm-debug.log

Cannot install module

Any help would be much appreciated.

λ ver
Microsoft Windows [Version 10.0.16299.492]

λ node -p -e "process.version + '-' + process.jsEngine"
v10.1.0-chakracore

λ npm install [email protected]
(node:11844) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

> [email protected] install C:\dev\example\node_modules\uwp
> node-gyp rebuild


C:\dev\example\node_modules\uwp>if not defined npm_config_node_gyp (node "C:\Users\wwwma\AppData\Local\nvs\chakracore\10.1.0\x64\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\wwwma\AppData\Local\nvs\chakracore\10.1.0\x64\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  uwp.cc
  win_delay_load_hook.cc
C:\dev\example\node_modules\nan\nan.h(138): warning C4005: 'TYPE_CHECK': macro redefinition (compiling source file ..\src\uwp.cc) [C:\dev\example\node_modules\uwp\build\uwp .vcxproj]
  C:\Users\wwwma\AppData\Local\nvs\chakracore\10.1.0\x64\sdk\deps\chakrashim\include\v8.h(88): note: see previous definition of 'TYPE_CHECK' (compiling source file ..\src\u
  wp.cc)
..\src\uwp.cc(75): error C2061: syntax error: identifier 'JsProjectionCallback' [C:\dev\example\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsCallback': lambda capture variable not found [C:\dev\example\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsContext': lambda capture variable not found [C:\dev\example\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3493: 'jsCallback' cannot be implicitly captured because no default capture mode has been specified [C:\dev\example\node_modules\uwp\build\uwp.vcx proj]
..\src\uwp.cc(77): error C3493: 'jsContext' cannot be implicitly captured because no default capture mode has been specified [C:\dev\example\node_modules\uwp\build\uwp.vcxp roj]
..\src\uwp.cc(74): error C3861: 'JsSetProjectionEnqueueCallback': identifier not found [C:\dev\example\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(104): error C3861: 'JsProjectWinRTNamespace': identifier not found [C:\dev\example\node_modules\uwp\build\uwp.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack    at onExit (C:\Users\wwwma\AppData\Local\nvs\chakracore\10.1.0\x64\node_modules\npm\node_modules\node-gyp\lib\build.js:258:7)
gyp ERR! stack    at Reflect.apply (native code:0:0)
gyp ERR! stack    at emit (events.js:182:5)
gyp ERR! stack    at _handle.onexit (internal/child_process.js:235:7)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Users\\wwwma\\AppData\\Local\\nvs\\chakracore\\10.1.0\\x64\\node.exe" "C:\\Users\\wwwma\\AppData\\Local\\nvs\\chakracore\\10.1.0\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\dev\example\node_modules\uwp
gyp ERR! node -v v10.1.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\dev\example\package.json'
npm WARN example No description
npm WARN example No repository field.
npm WARN example No README data
npm WARN example No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\wwwma\AppData\Roaming\npm-cache\_logs\2018-07-06T18_32_15_165Z-debug.log

Will this work in Electron shell?

I have created an app in Electron (http://electron.atom.io). It's basically a web application in a Chromium browser with NodeJS packed into an executable. My users can download and run this like it's a desktop application.

I'd like the app to connect to a Bluetooth Low Energy device through GATT in Windows 10. There is a UWP API for this that works. However I don't really feel like porting my app to a Windows Store app if I don't have to. So I came across this and it looks promising.

Now before I spend a lot of time and energy into trying to make this work, I'd like to ask you guys if you think it's possible at all. I'm sure I'm not the only person wondering this, thank you.

Error: 404 response downloading https://nodejs.org/dist/v7.0.0-pre8/node-v7.0.0-pre8.tar.gz

I am trying to follow the Hello Blinky tutorial sample, but have fallen at the first hurdle trying to install this. I have downloaded the node Chakra, opened that command line and then run npm install uwp --target_arch=arm (NB: I get the same result without the flagged argument).

This is what I get:

>npm i uwp --target_arch=arm

> [email protected] install C:\Users\George\Source\Repos\rpi_blink\node_modules\uwp
> node-gyp rebuild


C:\Users\George\Source\Repos\rpi_blink\node_modules\uwp>if not defined npm_config_node_gyp (node "C:\Users\George\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v7.0.0-pre8/node-v7.0.0-pre8.tar.gz
gyp ERR! stack    at Anonymous function (C:\Users\George\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\install.js:210:11)
gyp ERR! stack    at emitOne (events.js:101:7)
gyp ERR! stack    at emit (events.js:188:7)
gyp ERR! stack    at Request.prototype.onRequestResponse (C:\Users\George\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:954:5)
gyp ERR! stack    at emitOne (events.js:96:5)
gyp ERR! stack    at emit (events.js:188:7)
gyp ERR! stack    at parserOnIncomingClient (_http_client.js:472:3)
gyp ERR! stack    at parserOnHeadersComplete (_http_common.js:105:5)
gyp ERR! stack    at socketOnData (_http_client.js:361:3)
gyp ERR! stack    at emitOne (events.js:96:5)
gyp ERR! stack    at emit (events.js:188:7)
gyp ERR! stack    at readableAddChunk (_stream_readable.js:177:11)
gyp ERR! stack    at Readable.prototype.push (_stream_readable.js:135:3)
gyp ERR! stack    at onread (net.js:542:5)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\NodejsUwp\\Console\\node.exe" "C:\\Users\\George\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\George\Source\Repos\rpi_blink\node_modules\uwp
gyp ERR! node -v v7.0.0-pre8
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\George\Source\Repos\rpi_blink\package.json'
npm WARN rpi_blink No description
npm WARN rpi_blink No repository field.
npm WARN rpi_blink No README data
npm WARN rpi_blink No license field.
npm WARN You are using a pre-release version of node and things may not work as expected
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\NodejsUwp\\Console\\node.exe" "C:\\Users\\George\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "uwp" "--target_arch=arm"
npm ERR! node v7.0.0-pre8
npm ERR! npm  v3.10.7
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the uwp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs uwp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls uwp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\George\Source\Repos\rpi_blink\npm-debug.log

Looking at the nodejs dists, it seems as though there is in fact no v7.0.0-pre8 release, only v7.0.0, v7.1.0, v7.2.0, v7.2.1 ... v7.5.0.

Can we fix this please?

Error installing uwp

Hi there,
I'm having some issues installing with npm. I'm using VS2017, Node v9.2.0, npm v5.6.0. If anyone can point me in the right direction, that would be awesome! Let me know if you need any more info. Thanks!

Here is the error I'm getting :


D:\Code\NativexR>npm install uwp

> [email protected] install D:\Code\NativexR\node_modules\uwp
> node-gyp rebuild

D:\Code\NativexR\node_modules\uwp>if not defined npm_config_node_gyp (node "C:\Users\kyle\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\kyle\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  uwp.cc
  win_delay_load_hook.cc
..\src\uwp.cc(74): error C2065: 'JsErrorCode': undeclared identifier [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxpr
oj]
..\src\uwp.cc(74): error C2146: syntax error: missing ';' before identifier 'err' [D:\Code\NativexR\node_modules\uwp\bu
ild\uwp.vcxproj]
..\src\uwp.cc(74): error C2065: 'err': undeclared identifier [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(75): error C2061: syntax error: identifier 'JsProjectionCallback' [D:\Code\NativexR\node_modules\uwp\buil
d\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsCallback': lambda capture variable not found [D:\Code\NativexR\node_modules\uwp\buil
d\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsContext': lambda capture variable not found [D:\Code\NativexR\node_modules\uwp\build
\uwp.vcxproj]
..\src\uwp.cc(77): error C3493: 'jsCallback' cannot be implicitly captured because no default capture mode has been spe
cified [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3493: 'jsContext' cannot be implicitly captured because no default capture mode has been spec
ified [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(74): error C3861: 'JsSetProjectionEnqueueCallback': identifier not found [D:\Code\NativexR\node_modules\u
wp\build\uwp.vcxproj]
..\src\uwp.cc(82): error C2065: 'err': undeclared identifier [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(82): error C2065: 'JsNoError': undeclared identifier [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxproj
]
..\src\uwp.cc(104): error C3861: 'JsProjectWinRTNamespace': identifier not found [D:\Code\NativexR\node_modules\uwp\bui
ld\uwp.vcxproj]
..\src\uwp.cc(104): error C2065: 'JsNoError': undeclared identifier [D:\Code\NativexR\node_modules\uwp\build\uwp.vcxpro
j]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\kyle\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:159:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\kyle\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Code\NativexR\node_modules\uwp
gyp ERR! node -v v9.2.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of react-native@~0.50.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kyle\AppData\Roaming\npm-cache\_logs\2017-12-11T21_38_35_043Z-debug.log

Unable to use APIs available to real packages

Getting the following error when trying to get local/temp folders:

> Windows.Storage.ApplicationData.current
WinRTError: The process has no package identity.

I read around and looks like it's been a common issue for various UWP test runners, and in this specific case it happens because we don't really have any AppData associated with the script, but wondering if it would be possible to shim such APIs so that they would use e.g. script's folder as a base.

build: missing libs in LINK command line

Reported by @RReverser in #12. We should have a list of libs on LINK command line.

Those libs are supposed to be brought in by C:\Program Files\NodejsUwp\Console\node_modules\npm\node_modules\node-gyp\addon.gypi:

          ['node_win_onecore=="false"', {
            'libraries': [
              '-lkernel32.lib',
              '-luser32.lib',
              '-lgdi32.lib',
              '-lwinspool.lib',
              '-lcomdlg32.lib',
              '-ladvapi32.lib',
              '-lshell32.lib',
              '-lole32.lib',
              '-loleaut32.lib',
              '-luuid.lib',
              '-lodbc32.lib',
              '-lDelayImp.lib',
              '-l"<(node_lib_file)"',
            ],
          }],

But @RReverser only has 2:

Link:
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\Ingvar\Documents\Projects\Web\uwp-filesystem-shim\node_modules\u
  wp\build\Release\uwp.node" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files\NodejsUwp\Console\sdk\x64" chakrart.lib Delayimp.lib /DELAYLOAD:iojs.exe /DELAYLOAD:node.exe /
  MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"C:\Users\Ingvar\Documents\Projects\Web\uwp-filesystem-shim\node_modules\uwp\build\Re
  lease\uwp.pdb" /MAP /MAPINFO:EXPORTS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ignore:4199 /DLL Release\obj\uwp\uwp.obj
  Release\obj\uwp\win_delay_load_hook.obj
     Creating library C:\Users\Ingvar\Documents\Projects\Web\uwp-filesystem-shim\node_modules\uwp\build\Release\uwp.lib and object C:\Users\Ingvar\Documents\Projects\Web\uwp-
  filesystem-shim\node_modules\uwp\build\Release\uwp.exp
uwp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void * __cdecl v8::External::Value(void)const " (__imp_?Value@External@v8@@QEBAPEAXXZ) [C:\ Users\Ingvar\Documents\Projects\Web\uwp-filesystem-shim\node_modules\uwp\build\uwp.vcxproj]
...

uwp does not work from the REPL

21:54 $ node
> var uwp = require("uwp")
undefined
> uwp.projectNamespace("Windows")
undefined
> Windows
Error: Windows. (0x80000011): an unexpected failure occurred while trying to obtain metadata information
   at objectToString (util.js:706:3)
   at isRegExp (util.js:673:3)
   at formatValue (util.js:353:3)
   at inspect (util.js:107:3)
   at self.writer (repl.js:337:7)
   at finish (repl.js:458:9)
   at defaultEval (repl.js:269:5)
   at bound (domain.js:280:5)
   at runBound (domain.js:293:5)
   at Anonymous function (repl.js:412:7)

This only occurs when in the REPL. Running files works. So it's not really an issue, but I thought it could be mentioned somewhere, probably in the readme.

Incompatibility with nan 2.2.0

npm install uwp gave me some compile errors (please forgive my localized msbuild printing some messages in French):

"C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\binding.sln" (cible par défaut) (1) ->
"C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj" (cible par défaut) (2) ->
(ClCompile cible) ->
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(135): warning C4005: 'TYPE_CHECK': macro redefinition [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]


"C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\binding.sln" (cible par défaut) (1) ->
"C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj" (cible par défaut) (2) ->
(ClCompile cible) ->
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(605): error C2039: 'GCCallback': is not a member of 'v8::Isolate' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(605): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(605): error C2146: syntax error: missing ';' before identifier 'GCEpilogueCallback' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(606): error C2039: 'GCCallback': is not a member of 'v8::Isolate' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(611): error C2146: syntax error: missing ')' before identifier 'callback' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(611): error C2143: syntax error: missing ';' before '{' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(611): error C2447: '{': missing function header (old-style formal list?) [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(616): error C2146: syntax error: missing ')' before identifier 'callback' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(616): error C2143: syntax error: missing ';' before '{' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(616): error C2447: '{': missing function header (old-style formal list?) [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(623): error C2664: 'void v8::Isolate::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback,v8::GCType)': cannot convert argument 1 from 'Nan::GCPrologueCallback' to 'v8::Isolate ::GCPrologueCallback' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]
  C:\Dropbox\Coding\bb8-2\node_modules\nan\nan.h(628): error C2664: 'void v8::Isolate::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback)': cannot convert argument 1 from 'Nan::GCPrologueCallback' to 'v8::Isolate::GCProl ogueCallback' [C:\Dropbox\Coding\bb8-2\node_modules\uwp\build\uwp.vcxproj]

Since the errors were clearly complaining about nan, I thought I would check the version of nan that was used. Your package.json mentions ^2.1.0, which resolved to 2.2.0. I guessed that maybe you didn't test uwp with nan 2.2.0, so I cloned this repo on my disk, changed the nan version in package.json to ~2.1.0, ran npm i /path/to/my/cloned/uwp and it worked.

So maybe nan messed up and there is a breaking change between 2.1 and 2.2, or maybe uwp is using some internal nan APIs that were changed between 2.1 and 2.2. Anyway, a quick fix is to change the package.json nan dependency to ~2.1.0 or even 2.1.0.

Exceptions swallowed by promises

Reprising your sample and introducing an obvious mistake shows that errors don't seem to escape promise handlers:

var uwp = require('uwp');
uwp.projectNamespace("Windows");

Windows.Storage.KnownFolders.documentsLibrary.createFileAsync(
  "sample.dat", Windows.Storage.CreationCollisionOption.replaceExisting)
  .done(
    function (file) {
      undefinedFunc();
    },
    function (error) {
      undefinedFunc();
    }
);

Running this shows no error, it just runs eternally because uwp.close() is never called. It makes it hard to detect errors, especially programming ones.

I read about WinJS.promise.onerror, but I'm not sure how it relates to the uwp module. Any pointers?

How to List USB device?

my code:
DeviceInformation class

`
var uwp=require("uwp");

uwp.projectNamespace("Windows");
var deviceInformation = Windows.Devices.Enumeration.DeviceInformation;
var VID=0x10C4;
var PID=0x81B9;
deviceInformation.findAllAsync().done(
function(devices){
console.log(devices);
},function(err){
console.log(err);
}
);
`
result:
Windows.Devices.Enumeration.DeviceInformationCollection {
'0': Windows.Devices.Enumeration.DeviceInformation {},
'1': Windows.Devices.Enumeration.DeviceInformation {},
'2': Windows.Devices.Enumeration.DeviceInformation {},
'3': Windows.Devices.Enumeration.DeviceInformation {},
..........
'785': Windows.Devices.Enumeration.DeviceInformation {} }

why I can't find any device?

OS: Win 10 Enterprise
nodejs: Node.js (Chakra) [email protected]

The device can display at Device Manager

info:
USB\VID_10C4&PID_81B9\5&369d87d2&0&1。
input.inf
Guid: {745A17A0-74D3-11D0-B6FE-00A0C90F57DA}

Error trying to install the module

I've got this nex error: (I'm using windows 10)

  uwp.cc
  win_delay_load_hook.cc
..\src\uwp.cc(74): error C2065: 'JsErrorCode': undeclared identifier [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(74): error C2146: syntax error: missing ';' before identifier 'err' [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(74): error C2065: 'err': undeclared identifier [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(75): error C2061: syntax error: identifier 'JsProjectionCallback' [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsCallback': lambda capture variable not found [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3481: 'jsContext': lambda capture variable not found [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3493: 'jsCallback' cannot be implicitly captured because no default capture mode has been specified [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\
uwp\build\uwp.vcxproj]
..\src\uwp.cc(77): error C3493: 'jsContext' cannot be implicitly captured because no default capture mode has been specified [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\u
wp\build\uwp.vcxproj]
..\src\uwp.cc(74): error C3861: 'JsSetProjectionEnqueueCallback': identifier not found [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(82): error C2065: 'err': undeclared identifier [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(82): error C2065: 'JsNoError': undeclared identifier [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(104): error C3861: 'JsProjectWinRTNamespace': identifier not found [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
..\src\uwp.cc(104): error C2065: 'JsNoError': undeclared identifier [C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp\build\uwp.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\diego\Documents\ElectronJS Projects\Soube\node_modules\uwp
gyp ERR! node -v v6.10.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of ajv@>=5.0.4-beta.0 but none was installed.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "uwp" "--save-dev"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.

Using this without visual studio

Is it planned to be able to use this without the requirement of visual studio? Visual studio is very large and feels like overkill when I want to write a quick node script. I am use to using node with typescript and plugins that only work in the atom editor and it seems I need to learn a new workflow just to use windows api's in node.

When I want to use any open source library I can just npm install it. When I want to use windows API's i need to install a custom version of node, 10gb of visual studio and use Microsoft tools to build. This causes me a lot of friction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.