当前工作目录不是基于 Cordova 的项目

Current working directory is not a Cordova-based project

当 运行ning ionic cordova 运行 browser --verbose 在我的 Ionic4 项目的根目录中时,我收到错误 "Current working directory is not a Cordova-based project."。请参阅下面的错误输出。

我注意到该命令创建了一个 "www" 文件夹,但几秒钟后又将其删除。当我在删除文件夹后手动添加文件夹时(但命令仍然是 运行ning)我可以防止错误。但是 "www" 文件夹将保持为空,并且提供的网页将显示未找到文件。

Current working directory is not a Cordova-based project.
CordovaError: Current working directory is not a Cordova-based project.
at Object.cdProjectRoot (C:\nvm\v11.3.0\node_modules\cordova\node_modules\cordova-lib\src\cordova\util.js:170:15)
at C:\nvm\v11.3.0\node_modules\cordova\node_modules\cordova-lib\src\cordova\run.js:29:40
at _fulfilled (C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:854:54)
at C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:883:30
at Promise.promise.promiseDispatch (C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:816:13)
at C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:877:14
at runSingle (C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:137:13)
at flush (C:\nvm\v11.3.0\node_modules\cordova\node_modules\q\q.js:125:13)
at internalTickCallback (internal/process/next_tick.js:70:11)
at process._tickCallback (internal/process/next_tick.js:47:5)
[ERROR] An error occurred while running subprocess cordova.

    cordova run browser --verbose exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.
ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms
ionic:cli-framework:utils:process onBeforeExit handler: running 2 functions +1ms
ionic:cli-framework:utils:process error while killing process tree for 15736: { Error: Command failed: taskkill /pid 15736 /T /F
ionic:cli-framework:utils:process ERROR: The process "15736" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:294:12)
ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:182:13)
ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
ionic:cli-framework:utils:process   killed: false,
ionic:cli-framework:utils:process   code: 128,
ionic:cli-framework:utils:process   signal: null,
ionic:cli-framework:utils:process   cmd: 'taskkill /pid 15736 /T /F' } +288ms
ionic:cli-framework:utils:process onBeforeExit handler: error from function: { Error: Command failed: taskkill /pid 15736 /T /F
ionic:cli-framework:utils:process ERROR: The process "15736" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:294:12)
ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:182:13)
ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
ionic:cli-framework:utils:process   killed: false,
ionic:cli-framework:utils:process   code: 128,
ionic:cli-framework:utils:process   signal: null,
ionic:cli-framework:utils:process   cmd: 'taskkill /pid 15736 /T /F' } +6ms
ionic:cli-framework:utils:process error while killing process tree for 10672: { Error: Command failed: taskkill /pid 10672 /T /F
ionic:cli-framework:utils:process ERROR: The process "10672" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:294:12)
ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:182:13)
ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
ionic:cli-framework:utils:process     at Socket.stream.socket.on (internal/child_process.js:395:11)
ionic:cli-framework:utils:process     at Socket.emit (events.js:182:13)
ionic:cli-framework:utils:process     at Pipe._handle.close (net.js:616:12)
ionic:cli-framework:utils:process   killed: false,
ionic:cli-framework:utils:process   code: 128,
ionic:cli-framework:utils:process   signal: null,
ionic:cli-framework:utils:process   cmd: 'taskkill /pid 10672 /T /F' } +7ms
ionic:cli-framework:utils:process onBeforeExit handler: error from function: { Error: Command failed: taskkill /pid 10672 /T /F
ionic:cli-framework:utils:process ERROR: The process "10672" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:294:12)
ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:182:13)
ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
ionic:cli-framework:utils:process     at Socket.stream.socket.on (internal/child_process.js:395:11)
ionic:cli-framework:utils:process     at Socket.emit (events.js:182:13)
ionic:cli-framework:utils:process     at Pipe._handle.close (net.js:616:12)
ionic:cli-framework:utils:process   killed: false,
ionic:cli-framework:utils:process   code: 128,
ionic:cli-framework:utils:process   signal: null,
ionic:cli-framework:utils:process   cmd: 'taskkill /pid 10672 /T /F' } +6ms
ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 1) +8ms

详情

Ionic:

   ionic (Ionic CLI)             : 4.5.0 (C:\nvm\v11.3.0\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.15 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@ionic\angular)
   @angular-devkit/build-angular : 0.7.5 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@angular-devkit\build-angular)
   @angular-devkit/schematics    : 7.1.0
   @angular/cli                  : 7.1.0
   @ionic/angular-toolkit        : 1.2.0 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@ionic\angular-toolkit)

Cordova:

   cordova (Cordova CLI) : not installed
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   NodeJS : v11.3.0 (C:\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

尝试做一个 npm install。也许您的项目中缺少某些 Cordova 节点模块。

您是否尝试在 运行 命令之前创建 www 文件夹?

如果可行,请尝试将 www 文件夹添加到您的源代码管理系统(git、svn 等...),这样当您签出代码时,您就会创建该文件夹,从而防止构建系统尝试重新创建。

在您的 .gitignore 文件中(如果使用 git),添加以下行:

 # excludes everything inside the folder
www/*
# but do not exclude .gitkeep file, so the folder can be checked into the repository
!www/.gitkeep