npm start error:spawn powershell ENOENT

create react app创建了一个项目,然后npm start 报错spawn powershell  ENOENT。网上都说是环境变量问题,其实不完全正确。

正确的步骤如下:

一、检查C:\Windows\System32\WindowsPowerShell\v1.0目录下是否有powershell.exe文件。

   如果没有,需要先安装对应系统的powershell。我这里安装的是powershell5,给个链接: Microsoft 下载中心

  注意:下载后的msu文件不可以直接手动双击安装,这样会报错。

1.win+R键调出运行输入框,输入services.msc,回车打开服务管理器,找到windows update,看看是不是被禁用了,如果禁用了就双击,将启动类型改为自动或者手动才能启动windows update服务。

2.将系统更新文件(msu文件)的后缀改为cab并解压到一个新的文件夹。

3.管理员权限运行cmd,输入安装命令。

 管理员权限运行cmd,并输入以下命令:dism /online /add-package /packagepath:"路径/文件名.cab"。安装路径存在空格的时候,需要用双引号括起来,注意所有命令都应该使用英文字符(半角字符),包括双引号和冒号。

系统自动安装并提示安装成功,是否重启(Y/N):

输入Y,即可立即重启系统,完成更新。

 

二、配置环境变量。

 在系统变量的path中添加C:\Windows\System32\WindowsPowerShell\v1.0。

三、重新打开命令行或者重启电脑后打开命令行。

四、npm start,开始愉快地玩耍!

 

参考:

Windows更新失败,错误代码0x80240037解决办法

 

已标记关键词 清除标记
相关推荐
<div><p>CLI version is 2.5.2 OS is Windows 10 Node 6.3.1 (with Nodist VM)</p> <h1>Trying to create any type of project</h1> <pre><code> tns create Groceries --template nativescript-template-ng-groceries --log trace > out.txt </code></pre> <h1>Results in:</h1> <pre><code> execFile: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platform-tools\adb "help" execFile: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platform-tools\adb "help" spawn: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platform-tools\adb "--help" Socket { connecting: false, _hadError: false, _handle: Pipe { bytesRead: 0, _externalStream: {}, fd: -1, writeQueueSize: 0, owner: [Circular], onread: [Function: onread], reading: true }, _parent: null, _host: null, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: null, pipesCount: 0, flowing: null, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, defaultEncoding: 'utf8', ranOut: false, awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: { [Function: g] listener: [Function: onend] }, finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], close: [Function] }, _eventsCount: 4, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, needDrain: false, ending: false, ended: false, finished: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: CorkedRequest { next: null, entry: null, finish: [Function] } }, writable: false, allowHalfOpen: false, destroyed: false, _bytesDispatched: 0, _sockname: null, _writev: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null } Exec npm -v stdout: 3.10.6 stderr: spawn: java "-version" Exec node-gyp -v stdout: stderr: 'node-gyp' is not recognized as an internal or external command, operable program or batch file. Exec "C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platform-tools\adb" version stdout: Android Debug Bridge version 1.0.36 Revision 0e9850346394-android stderr: spawn: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\tools\android.bat "-h" Result when throw error is false: { stdout: '\n Usage:\n android [global options] action [action options]\n Global options:\n -s --silent : Silent mode, shows errors only.\n -v --verbose : Verbose mode, shows errors, warnings and all messages.\n --clear-cache: Clear the SDK Manager repository manifest cache.\n -h --help : Help on a specific command.\n\n Valid\n actions\n are\n composed\n of a verb\n and an\n optional\n direct\n object:\n- sdk : Displays the SDK Manager window.\n- avd : Displays the AVD Manager window.\n- list : Lists existing targets or virtual devices.\n- list avd : Lists existing Android Virtual Devices.\n- list target : Lists existing targets.\n- list device : Lists existing devices.\n- list sdk : Lists remote SDK repository.\n- create avd : Creates a new Android Virtual Device.\n- move avd : Moves or renames an Android Virtual Device.\n- delete avd : Deletes an Android Virtual Device.\n- update avd : Updates an Android Virtual Device to match the folders\n of a new SDK.\n- create project : Creates a new Android project.\n- update project : Updates an Android project (must already have an\n AndroidManifest.xml).\n- create test-project : Creates a new Android project for a test package.\n- update test-project : Updates the Android project for a test package (must\n already have an AndroidManifest.xml).\n- create lib-project : Creates a new Android library project.\n- update lib-project : Updates an Android library project (must already have\n an AndroidManifest.xml).\n- create uitest-project: Creates a new UI test project.\n- update adb : Updates adb to support the USB devices declared in the\n SDK add-ons.\n- update sdk : Updates the SDK by suggesting new platforms to install\n if available.\n', stderr: '', exitCode: 0 } Exec mono --version stdout: stderr: 'mono' is not recognized as an internal or external command, operable program or batch file. Exec git --version stdout: git version 2.9.0.windows.1 stderr: Exec gradle -v stdout: stderr: 'gradle' is not recognized as an internal or external command, operable program or batch file. Exec "C:\Program Files\Java\jdk1.8.0_112\bin\javac" -version stdout: stderr: javac 1.8.0_112 System information: { procInfo: 'nativescript/2.5.2', platform: 'win32', os: 'Windows 10 Home 6.3.14393', shell: 'C:\\WINDOWS\\system32\\cmd.exe', dotNetVer: '4.6.01586', procArch: 'x64', nodeVer: 'v6.3.1', npmVer: '3.10.6', javaVer: '1.8.0', nodeGypVer: null, xcodeVer: null, xcodeprojGemLocation: null, itunesInstalled: true, cocoapodVer: null, adbVer: 'Android Debug Bridge version 1.0.36', androidInstalled: true, monoVer: null, gitVer: '2.9.0.windows.1', gradleVer: null, javacVersion: '1.8.0_112' } Starting watch on killswitch C:\Users\Joel\AppData\Local\Temp\Joel\KillSwitches\cli Initializing analytics statuses. Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track feature 'Non-interactive' with value 'create'. Creating a new NativeScript project with name Groceries and id org.nativescript.Groceries at location C:\Users\Joel\Development\Groceries Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track feature 'Template used for project creation' with value 'nativescript-template-ng-groceries'. Using NativeScript verified template: nativescript-template-ng-groceries with version undefined. Exec npm view nativescript-template-ng-groceries --json dist-tags stdout: { "latest": "1.0.0" } stderr: Using version 1.0.0. Exec npm view nativescript-template-ng-groceries --json versions stdout: [ "0.1.0", "1.0.0" ] stderr: Installing nativescript-template-ng-groceries spawn: npm.cmd "install" "nativescript-template-ng-groceries.0.0" "--silent" "--save" { Error: spawn npm.cmd ENOENT at FiberFuture.Future.wait (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:566:15) at error (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\lib\npm-installation-manager.js:43:96) at Function.settle (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:249:26) at FiberFuture.Future.wait (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:565:10) at C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\lib\services\project-templates-service.js:24:106 at Function.settle (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:249:26) at FiberFuture.Future.wait (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:565:10) at err (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\lib\services\project-service.js:58:112) at Function.settle (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:249:26) at FiberFuture.Future.wait (C:\Program Files (x86)\Nodist\bin\node_modules\nativescript\node_modules\fibers\future.js:565:10) - - - - - at exports._errnoException (util.js:1012:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32) at onErrorNT (internal/child_process.js:348:16) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn npm.cmd', path: 'npm.cmd', spawnargs: [ 'install', 'nativescript-template-ng-groceries.0.0', '--silent', '--save' ] } Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track feature 'Non-interactive' with value 'help'. List of registered commands: /?, appstore, appstore|upload, autocomplete, autocomplete|disable, autocomplete|enable, autocomplete|status, build, build|android, build|ios, clean-app, clean-app|android, clean-app|ios, create, debug, debug|android, debug|ios, deploy, dev-generate-help, dev-generate-messages, dev-post-install, dev-preuninstall, dev-test, dev-test|android, dev-test|ios, device, devices, device|android, device|get-file, device|ios, device|list-applications, device|list-files, device|log, device|put-file, device|run, device|stop, device|uninstall, doctor, emulate, emulate|android, emulate|ios, error-reporting, help, info, init, install, livesync, platform, platform|add, platform|clean, platform|remove, platform|update, plugin, plugin|add, plugin|find, plugin|install, plugin|remove, plugin|search, plugin|update, post-install-cli, prepare, publish, publish|ios, run, run|android, run|ios, test, test|android, test|init, test|ios, update, usage-reporting Reading help for command 'create'. FileName is 'create.md'. # create ┌─────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Usage │ Synopsis │ │ Create from default JavaScript template │ $ tns create <app name> [--path <directory>] [--appid <app id>] │ │ Create from default TypeScript template │ $ tns create <app name> --template typescript [--path <directory>] [--appid <app id>] OR $ tns create <app name> --tsc [--path <directory>] [--appid <app id>] OR $ tns create <app name> --template tsc [--path <directory>] [--appid <app id>] │ │ Create from default Angular template │ $ tns create <app name> --template angular [--path <directory>] [--appid <app id>] OR $ tns create <app name> --template ng [--path <directory>] [--appid <app id>] OR $ tns create <app name> --ng [--path <directory>] [--appid <app id>] │ │ Copy from existing project │ $ tns create <app name> [--path <directory>] [--appid <app id>] --copy-from <directory> │ │ Create from custom template │ $ tns create <app name> [--path <directory>] [--appid <app id>] --template <template> │ └─────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ Creates a new project for native development with NativeScript. ### Options * --path - Specifies the directory where you want to create the project, if different from the current directory. The directory must be empty. * --appid - Sets the application identifier for your project. * --copy-from - Specifies a directory which contains an existing NativeScript project. If --copy-from and --template are not set, the NativeScript CLI creates the project from the default JavaScript hello-world template. * --template - Specifies a valid npm package which you want to use to create your project. If --copy-from and --template are not set, the NativeScript CLI creates the project from the default JavaScript hello-world template. * --ng - Sets the template for your project to the Angular template. * --tsc - Sets the template for your project to the TypeScript template. ### Attributes * <app name> is the name of project. The specified name must meet the requirements of all platforms that you want to target. For more information about the <app name> requirements, run $ tns help create * <app id> is the application identifier for your project. It must be a domain name in reverse and must meet the requirements of all platforms that you want to target. If not specified, the application identifier is set to org.nativescript.<app name> For more information about the <app id> requirements, run $ tns help create Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track exception with message 'Error: spawn npm.cmd ENOENT'. </app></app></app></app></app></template></app></directory></app></directory></app></directory></app></app></directory></app></app></directory></app></app></directory></app></app></directory></app></app></directory></app></app></directory></app></app></directory></app></code></pre> <h1><code>tns doctor</code> Indicates that everything is fine:</h1> <pre><code> execFile: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\plat form-tools\adb "help" execFile: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\plat form-tools\adb "help" spawn: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platfor m-tools\adb "--help" Socket { connecting: false, _hadError: false, _handle: Pipe { bytesRead: 0, _externalStream: {}, fd: -1, writeQueueSize: 0, owner: [Circular], onread: [Function: onread], reading: true }, _parent: null, _host: null, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: null, pipesCount: 0, flowing: null, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, defaultEncoding: 'utf8', ranOut: false, awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: { [Function: g] listener: [Function: onend] }, finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], close: [Function] }, _eventsCount: 4, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, needDrain: false, ending: false, ended: false, finished: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: CorkedRequest { next: null, entry: null, finish: [Funct ion] } }, writable: false, allowHalfOpen: false, destroyed: false, _bytesDispatched: 0, _sockname: null, _writev: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null } Exec npm -v stdout: 3.10.6 stderr: spawn: java "-version" Exec node-gyp -v stdout: stderr: 'node-gyp' is not recognized as an internal or external command, operable program or batch file. Exec "C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\platform -tools\adb" version stdout: Android Debug Bridge version 1.0.36 Revision 0e9850346394-android stderr: spawn: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\tools\a ndroid.bat "-h" Result when throw error is false: { stdout: '\n Usage:\n android [global options] action [action optio ns]\n Global options:\n -s --silent : Silent mode, shows errors only. \n -v --verbose : Verbose mode, shows errors, warnings and all messages.\n --clear-cache: Clear the SDK Manager repository manifest cache.\n -h --help : Help on a specific command.\n\n Valid\n actions\n are\n composed\n of a verb\n and an\n optional\n direct\n o bject:\n- sdk : Displays the SDK Manager window.\n- avd : Displays the AVD Manager window.\n- list : Lists existi ng targets or virtual devices.\n- list avd : Lists existing Android V irtual Devices.\n- list target : Lists existing targets.\n- list devic e : Lists existing devices.\n- list sdk : Lists remote SDK repo sitory.\n- create avd : Creates a new Android Virtual Device.\n- move avd : Moves or renames an Android Virtual Device.\n- delete avd : Deletes an Android Virtual Device.\n- update avd : Updates an Andr oid Virtual Device to match the folders\n of a new SDK.\n - create project : Creates a new Android project.\n- update project : Updates an Android project (must already have an\n Androi dManifest.xml).\n- create test-project : Creates a new Android project for a tes t package.\n- update test-project : Updates the Android project for a test packa ge (must\n already have an AndroidManifest.xml).\n- creat e lib-project : Creates a new Android library project.\n- update lib-project : Updates an Android library project (must already have\n an AndroidManifest.xml).\n- create uitest-project: Creates a new UI test project .\n- update adb : Updates adb to support the USB devices declared in th e\n SDK add-ons.\n- update sdk : Updates the SDK by suggesting new platforms to install\n if available.\n ', stderr: '', exitCode: 0 } Exec mono --version stdout: stderr: 'mono' is not recognized as an internal or external command, operable program or batch file. Exec git --version stdout: git version 2.9.0.windows.1 stderr: Exec gradle -v stdout: stderr: 'gradle' is not recognized as an internal or external command, operable program or batch file. Exec "C:\Program Files\Java\jdk1.8.0_112\bin\javac" -version stdout: stderr: javac 1.8.0_112 System information: { procInfo: 'nativescript/2.5.2', platform: 'win32', os: 'Windows 10 Home 6.3.14393', shell: 'C:\\WINDOWS\\system32\\cmd.exe', dotNetVer: '4.6.01586', procArch: 'x64', nodeVer: 'v6.3.1', npmVer: '3.10.6', javaVer: '1.8.0', nodeGypVer: null, xcodeVer: null, xcodeprojGemLocation: null, itunesInstalled: true, cocoapodVer: null, adbVer: 'Android Debug Bridge version 1.0.36', androidInstalled: true, monoVer: null, gitVer: '2.9.0.windows.1', gradleVer: null, javacVersion: '1.8.0_112' } Starting watch on killswitch C:\Users\Joel\AppData\Local\Temp\Joel\KillSwitches\ cli Looking for project in 'C:\Users\Joel\Development' Looking for project in 'C:\Users\Joel' Looking for project in 'C:\Users' Looking for project in 'C:\' No project found at or above 'C:\Users\Joel\Development'. No project found at or above '%s' and neither was a --path specified. Initializing analytics statuses. Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track feature 'Non-interactive' with value 'doctor'. execFile: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\plat form-tools\adb "help" NOTE: You can develop for iOS only on Mac OS X systems. To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later. spawn: C:\Users\Joel\Local Settings\Application Data\Android\android-sdk\tools\a ndroid.bat "list" "targets" Result when throw error is false: { stdout: 'Available Android targets:\n----------\nid: 1 or "android-23"\n N ame: Android 6.0\n Type: Platform\n API level: 23\n Revision: 3\n Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA 720, WXGA800, WXGA800-7in\n Tag/ABIs : default/x86\n----------\nid: 2 or "androi d-25"\n Name: Android 7.1.1\n Type: Platform\n API level: 25\n R evision: 1\n Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default) , WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : android-tv/x86, google_api s/x86, google_apis/x86_64\n', stderr: '', exitCode: 0 } Available Android targets: ---------- id: 1 or "android-23" Name: Android 6.0 Type: Platform API level: 23 Revision: 3 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W XGA720, WXGA800, WXGA800-7in Tag/ABIs : default/x86 ---------- id: 2 or "android-25" Name: Android 7.1.1 Type: Platform API level: 25 Revision: 1 Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W XGA720, WXGA800, WXGA800-7in Tag/ABIs : android-tv/x86, google_apis/x86, google_apis/x86_64 Directories found in C:\Users\Joel\Local Settings\Application Data\Android\andro id-sdk\build-tools are 23.0.3, 25.0.2 Versions found in C:\Users\Joel\Local Settings\Application Data\Android\android- sdk\build-tools are 23.0.3, 25.0.2 Selected version is: 25.0.2 Selected targetSdk is: 25 Directories found in C:\Users\Joel\Local Settings\Application Data\Android\andro id-sdk\extras\android\m2repository\com\android\support\appcompat-v7 are 18.0.0, 19.0.0, 19.0.1, 19.1.0, 20.0.0, 21.0.0, 21.0.2, 21.0.3, 22.0.0, 22.1.0, 22.1.1, 22.2.0, 22.2.1, 23.0.0, 23.0.1, 23.1.0, 23.1.1, 23.2.0, 23.2.1, 23.3.0, 23.4.0, 24.0.0, 24.0.0-alpha1, 24.0.0-alpha2, 24.0.0-beta1, 24.1.0, 24.1.1, 24.2.0, 24.2 .1, 25.0.0, 25.0.1, 25.1.0, 25.1.1, 25.2.0, maven-metadata.xml, maven-metadata.x ml.md5, maven-metadata.xml.sha1 Versions found in C:\Users\Joel\Local Settings\Application Data\Android\android- sdk\extras\android\m2repository\com\android\support\appcompat-v7 are 18.0.0, 19. 0.0, 19.0.1, 19.1.0, 20.0.0, 21.0.0, 21.0.2, 21.0.3, 22.0.0, 22.1.0, 22.1.1, 22. 2.0, 22.2.1, 23.0.0, 23.0.1, 23.1.0, 23.1.1, 23.2.0, 23.2.1, 23.3.0, 23.4.0, 24. 0.0, 24.0.0, 24.0.0, 24.0.0, 24.1.0, 24.1.1, 24.2.0, 24.2.1, 25.0.0, 25.0.1, 25. 1.0, 25.1.1, 25.2.0 Selected version is: 25.2.0 Selected AppCompat version is: 25.2.0 Analytics statuses: { TrackFeatureUsage: 1, TrackExceptions: 1 } Trying to track feature 'DoctorEnvironmentSetup' with value 'correct'. Exec npm view nativescript --json dist-tags stdout: { "latest": "2.5.2", "next": "3.0.0-2017-03-09-8199" } stderr: Using version 2.5.2. Exec npm view tns-core-modules --json dist-tags stdout: { "latest": "2.5.1", "angular": "2.0.0-angular-7", "css-animations": "1.6.2-css-animations-0", "next": "2.6.0-2017-02-08-5576", "uglify": "2.4.3-uglify", "internal-preview": "3.0.0-2017-03-09-5920" } stderr: Using version 2.5.1. Exec npm view tns-android --json dist-tags stdout: { "latest": "2.5.0", "next": "3.0.0-next-2017-03-08-1689" } stderr: Using version 2.5.0. Exec npm view tns-ios --json dist-tags stdout: { "latest": "2.5.0", "exp-ios-8.2": "0.9.2-exp-ios-8.2", "next": "2.6.0-2017-2-6-1" } stderr: Using version 2.5.0. Your components are up-to-date. No issues were detected. </code></pre><p>该提问来源于开源项目:NativeScript/nativescript-cli</p></div>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页