ns create 无法创建工作项目
ns create cannot create a working project
我执行以下操作:
ns create HelloNg --template @nativescript/template-tab-navigation-ng
ns create BlankNg --template @nativescript/template-blank-ng
ns create Blank --template @nativescript/template-blank
ns create Create
# allways finished with:
Project xyz was successfully created.
# after change the working directory to the project folder, i try to run/debug
ns run android
ns debug android
我总是遇到同样的错误:Cannot read properties of null (reading 'forEach')
ns doctor android
输出为:未检测到任何问题。
系统:Ubuntu20.04
NativeScript 8.2.2
npm 8.3.1
节点 v16.14.0
我能做什么?
[编辑]
$ ns clean
⠋ Cleaning project...
✔ Cleaned directory hooks
ℹ Skipping platforms because it doesn't exist.
✔ Cleaned directory node_modules
✔ Cleaned file package-lock.json
✔ Project successfully cleaned.
$ ns run android
Cannot read properties of null (reading 'forEach')
$ tns platform add android
Copying template files...
Cannot read properties of null (reading 'latest')
$ ns run android
Cannot read properties of null (reading 'forEach')
$ ns clean
⠋ Cleaning project...
ℹ Skipping hooks because it doesn't exist.
✔ Cleaned directory platforms
ℹ Skipping node_modules because it doesn't exist.
ℹ Skipping package-lock.json because it doesn't exist.
✔ Project successfully cleaned.
[编辑]
现在 --log trace
$ ns debug android --log trace
TypeError: Cannot read properties of null (reading 'forEach')
at Object.maxSatisfying (/usr/lib/node_modules/nativescript/node_modules/semver/ranges/max-satisfying.js:13:12)
at PackageInstallationManager.<anonymous> (/usr/lib/node_modules/nativescript/lib/package-installation-manager.js:56:27)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/nativescript/lib/package-installation-manager.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Cannot read properties of null (reading 'forEach')
这个错误听起来像是来自您自己的代码。您在某处使用 forEach 并且对象为空。如果您在控制台日志中进一步查看,您可以看到准确的行号。
我发现了错误。 Node.js 作为 snap 包安装。这导致各种工具出现问题。
现在 Node.js 已从 node.tar.xz 安装到我的主目录中,一切正常。
我执行以下操作:
ns create HelloNg --template @nativescript/template-tab-navigation-ng
ns create BlankNg --template @nativescript/template-blank-ng
ns create Blank --template @nativescript/template-blank
ns create Create
# allways finished with:
Project xyz was successfully created.
# after change the working directory to the project folder, i try to run/debug
ns run android
ns debug android
我总是遇到同样的错误:Cannot read properties of null (reading 'forEach')
ns doctor android
输出为:未检测到任何问题。
系统:Ubuntu20.04
NativeScript 8.2.2
npm 8.3.1
节点 v16.14.0
我能做什么?
[编辑]
$ ns clean
⠋ Cleaning project...
✔ Cleaned directory hooks
ℹ Skipping platforms because it doesn't exist.
✔ Cleaned directory node_modules
✔ Cleaned file package-lock.json
✔ Project successfully cleaned.
$ ns run android
Cannot read properties of null (reading 'forEach')
$ tns platform add android
Copying template files...
Cannot read properties of null (reading 'latest')
$ ns run android
Cannot read properties of null (reading 'forEach')
$ ns clean
⠋ Cleaning project...
ℹ Skipping hooks because it doesn't exist.
✔ Cleaned directory platforms
ℹ Skipping node_modules because it doesn't exist.
ℹ Skipping package-lock.json because it doesn't exist.
✔ Project successfully cleaned.
[编辑]
现在 --log trace
$ ns debug android --log trace
TypeError: Cannot read properties of null (reading 'forEach')
at Object.maxSatisfying (/usr/lib/node_modules/nativescript/node_modules/semver/ranges/max-satisfying.js:13:12)
at PackageInstallationManager.<anonymous> (/usr/lib/node_modules/nativescript/lib/package-installation-manager.js:56:27)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/nativescript/lib/package-installation-manager.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Cannot read properties of null (reading 'forEach')
这个错误听起来像是来自您自己的代码。您在某处使用 forEach 并且对象为空。如果您在控制台日志中进一步查看,您可以看到准确的行号。
我发现了错误。 Node.js 作为 snap 包安装。这导致各种工具出现问题。
现在 Node.js 已从 node.tar.xz 安装到我的主目录中,一切正常。