0

我正在尝试学习 NativeScript。我已完成以下步骤在我的 windows 8.1 Pro 64 位机器上安装 NativeScript:

  1. 在 D 盘上安装 node.js (node-v8.11.2-x64)
  2. 在 D 盘上安装 Visual Studio Code (VSCodeSetup-x64-1.23.1)
  3. 在 D 盘上安装 Git (Git-2.17.0-64-bit)
  4. 在 D 盘上安装 Android Studio (android-studio-ide-173.4720617-windows)
  5. 使用以下命令安装 NativeScript:npm install -g nativescript。

我在第 5 步收到以下错误:

C:\Users\UserName>npm install -g nativescript
nativescript@4.0.1 preuninstall C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript

node preuninstall.js

Failed to complete all pre-uninstall steps.

C:\Users\UserName\AppData\Roaming\npm\tns -> C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\bin\tns

C:\Users\UserName\AppData\Roaming\npm\nativescript -> C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\bin\tns

> nativescript@4.0.1 postinstall C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript

> node postinstall.js

RangeError: Maximum call stack size exceeded

at normalizeStringWin32 (path.js:33:30)

at Object.resolve (path.js:328:20)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:68:14)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:77:24)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\nativescript\node_modules\fsevents):

    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ nativescript@4.0.1

updated 1 package in 18.244s

当我运行 tns doctor 命令时,我收到以下信息:

> C:\Users\UserName>tns doctor
> 
> RangeError: Maximum call stack size exceeded
> 
>     at normalizeStringWin32 (path.js:33:30)
> 
>     at Object.resolve (path.js:328:20)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:68:14)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:77:24)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)
> 
>     at sync (C:\Users\UserName\AppData\Roaming\npm\node_modules\nativescript\node_modules\mkdirp\index.js:78:17)

我也尝试卸载 NativeScript,但它仍然卡在 resolveWithNewModule 上,见下文:

C:\Users\UserName>npm uninstall -g  nativescript

[  ................] / loadDep:readdirp: sill resolveWithNewModule xcode@0.8.0 checking installable status

我的问题是:

  1. 如何修复 NativeScript 的安装错误?
  2. 如果我需要卸载 NativeScript,我该怎么做?
  3. 哪个目录 NativeScript 使用已安装的命令安装,我可以将它安装在 d 驱动器上吗?
4

2 回答 2

1

看起来安装过程内存不足。在运行安装之前尝试运行此命令:

node --max-old-space-size=8192

根据您机器上安装的 RAM 设置最后一个数字(2048、4096 ecc)

于 2018-05-17T10:18:41.540 回答
0

@Aaron Ullal 是对的,原因主要是 NodeJS 堆(V8 中的内存使用)耗尽了可用内存,并不是因为您没有剩余内存,这是 node exec 配置中包含的硬停止。

你可以添加一个标志来增加堆大小

NODE_OPTIONS="--max-old-space-size=4096" node

您可以在此处找到更多信息。请使用搜索工具查找类似的错误或已回答的问题

于 2020-09-17T18:03:50.873 回答