【问题标题】:Cordova create project error: Error: Uncaught, unspecified "error" eventCordova 创建项目错误:错误:未捕获,未指定的“错误”事件
【发布时间】:2017-07-29 09:08:31
【问题描述】:

我正在使用 Cordova 7.0.1 以及 node v7.10.1npm 4.2.0ubuntu 16.04

但是当我尝试开始一个新项目时,我得到了以下错误:

Error: Uncaught, unspecified "error" event. (  Error from Cordova Fetch: Error: npm: Command failed with exit code 254 Error output:
npm ERR! not a package /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
npm ERR! addLocal Could not install /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
npm ERR! Linux 4.10.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! path /tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/alfred/.npm/_logs/2017-07-29T09_01_02_256Z-debug.log)

还有~/.npm/_logs/2017-07-29T09_01_02_256Z-debug.log 文件:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli   '/usr/bin/npm',
1 verbose cli   'install',
1 verbose cli   '/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js' ]
2 info using npm@4.2.0
3 info using node@v7.10.1
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
8 silly fetchOtherPackageData /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
9 silly cache add args [ '/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js',
9 silly cache add   null ]
10 verbose cache add spec /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
11 silly cache add parsed spec Result {
11 silly cache add   raw: '/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js',
11 silly cache add   scope: null,
11 silly cache add   escapedName: null,
11 silly cache add   name: null,
11 silly cache add   rawSpec: '/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js',
11 silly cache add   spec: '/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js',
11 silly cache add   type: 'local' }
12 silly addLocalTarball shasum (computed) 68d804862643855bd46c9138146b64789601b1da
13 verbose addTmpTarball /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js not in flight; adding
14 verbose correctMkdir /home/alfred/.npm correctMkdir not in flight; initializing
15 verbose addTmpTarball validating metadata from /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
16 verbose tar unpack /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
17 verbose tar unpacking to /tmp/npm-19210-c6225b45/unpack-1e28fcae
18 silly gentlyRm /tmp/npm-19210-c6225b45/unpack-1e28fcae is being purged
19 verbose gentlyRm don't care about contents; nuking /tmp/npm-19210-c6225b45/unpack-1e28fcae
20 silly gunzTarPerm modes [ '755', '644' ]
21 error not a package /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
22 error addLocal Could not install /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js
23 silly fetchPackageMetaData Error: ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
23 silly fetchPackageMetaData  error for /usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js { Error: ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
23 silly fetchPackageMetaData   errno: -2,
23 silly fetchPackageMetaData   code: 'ENOENT',
23 silly fetchPackageMetaData   syscall: 'open',
23 silly fetchPackageMetaData   path: '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json' }
24 silly rollbackFailedOptional Starting
25 silly rollbackFailedOptional Finishing
26 silly runTopLevelLifecycles Finishing
27 silly install printInstalled
28 verbose stack Error: ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
29 verbose cwd /home/alfred/.cordova/node_modules
30 error Linux 4.10.0-28-generic
31 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "/usr/lib/node_modules/cordova/node_modules/_cordova-app-hello-world@3.12.0@cordova-app-hello-world/index.js"
32 error node v7.10.1
33 error npm  v4.2.0
34 error path /tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json
35 error code ENOENT
36 error errno -2
37 error syscall open
38 error enoent ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
39 error enoent ENOENT: no such file or directory, open '/tmp/npm-19210-c6225b45/unpack-1e28fcae/package.json'
39 error enoent This is most likely not a problem with npm itself
39 error enoent and is related to npm not being able to find a file.
40 verbose exit [ -2, true ]

【问题讨论】:

    标签: node.js cordova ubuntu cross-platform phonegap


    【解决方案1】:

    在cordova中创建新项目,命令是

    cordova create FolderName PackageName ProjectName 
    

    例如我想创建名为“cordova-test”的项目,那么命令是

    cordova create cordova-test com.example cordova-test
    

    它会为你工作。

    【讨论】:

    • 不是问题,我打印的同一命令在另一台机器上工作,当我打印完整命令时我的问题仍然存在。
    猜你喜欢
    • 2018-01-06
    • 2013-10-27
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    相关资源
    最近更新 更多