我遵循developer guide上的说明,但是当我进行编译时,它失败了,出现了这个错误。
> mocha -t 0 --recursive && cucumber-js
Sample
1) "before each" hook for "Alice can read all of the assets"
0 passing (912ms)
1 failing
1) Sample "before each" hook for "Alice can read all of the assets":
SyntaxError: Failed to parse /Users/calvinlin007/Documents/hyperledger-composer/my-network/lib/sample.js: The keyword 'const' is reserved (17:0)
at new Script (node_modules/composer-common/lib/introspect/script.js:55:27)
at ScriptManager.createScript (node_modules/composer-common/lib/scriptmanager.js:61:16)
at Object.process (node_modules/composer-common/lib/businessnetworkdefinition.js:507:69)
at Function.processFile (node_modules/composer-common/lib/businessnetworkdefinition.js:578:27)
at items.forEach (node_modules/composer-common/lib/businessnetworkdefinition.js:563:39)
at Array.forEach (native)
at Function.processDirectory (node_modules/composer-common/lib/businessnetworkdefinition.js:562:15)
at Function.fromDirectory (node_modules/composer-common/lib/businessnetworkdefinition.js:498:35)
at adminConnection.createProfile.then.then (test/sample.js:66:50)
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test-inner"
npm ERR! node v6.11.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! my-network@0.1.6 test-inner: `mocha -t 0 --recursive && cucumber-js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-network@0.1.6 test-inner script 'mocha -t 0 --recursive && cucumber-js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-network package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha -t 0 --recursive && cucumber-js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs my-network
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls my-network
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/calvinlin007/Documents/hyperledger-composer/my-network/npm-debug.log
npm ERR! Test failed. See above for more details.这是我的.eslintrc.yml配置
env:
es6: true
node: true
mocha: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 2015
sourceType:
- script因为我已经搜索了这个问题,应该是EMCAScript版本,但是我试着改变它,但它没有工作。
我查过了我的macOS是10.12。这是我的package.json
{
"engines": {
"composer": "^0.11.0 || ^0.12.0 || ^0.13.0"
},
"name": "my-network",
"version": "0.1.6",
"description": "My Commodity Trading network",
"networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample-network/networkimage.svg",
"networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample-network/networkimageanimated.svg",
"scripts": {
"prepublish": "mkdirp ./dist ; composer archive create --sourceType dir --sourceName . -a ./dist/my-network.bna",
"pretest": "npm run lint",
"lint": "eslint .",
"postlint": "npm run licchk",
"licchk": "license-check",
"postlicchk": "npm run doc",
"doc": "jsdoc --pedantic --recurse -c jsdoc.json",
"test-inner": "mocha -t 0 --recursive && cucumber-js",
"test-cover": "nyc npm run test-inner",
"test": "npm run test-inner"
},
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/composer-sample-networks.git"
},
"keywords": [
"sample",
"composer",
"composer-network"
],
"author": "Hyperledger Composer",
"license": "Apache-2.0",
"devDependencies": {
"browserfs": "^1.2.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"composer-admin": "^0.11.0",
"composer-cli": "^0.11.0",
"composer-client": "^0.11.0",
"composer-connector-embedded": "^0.11.0",
"composer-cucumber-steps": "^0.11.0",
"cucumber": "^2.2.0",
"eslint": "^3.6.1",
"istanbul": "^0.4.5",
"jsdoc": "^3.4.1",
"license-check": "^1.1.5",
"mkdirp": "^0.5.1",
"mocha": "^3.2.0",
"moment": "^2.17.1",
"nyc": "^11.0.2"
},
"license-check-config": {
"src": [
"**/*.js",
"!./coverage/**/*",
"!./node_modules/**/*",
"!./out/**/*",
"!./scripts/**/*"
],
"path": "header.txt",
"blocking": true,
"logInfo": false,
"logError": true
},
"nyc": {
"exclude": [
"coverage/**",
"features/**",
"out/**",
"test/**"
],
"reporter": [
"text-summary",
"html"
],
"all": true,
"check-coverage": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
}有人知道如何解决这个问题吗@?
发布于 2017-09-19 13:02:38
在第一个问题-- sample.js测试脚本--您将单元测试脚本内容复制到lib/sample.js中,这就是为什么您有问题--即'const‘错误--该文件是事务处理程序函数脚本。您应该(根据开发人员教程)将单元测试脚本粘贴到位于test/sample.js的文件中。我认为,文件名(在“lib”和“test”子目录中)是相同的,这可能造成了一些混乱--我想我会修改它以改善用户体验。另一个角误差(前面提到)仍然存在。
在你的第二次投递(角度模块错误)。本地Composer操场安装依赖于角(注意,开发人员指南使用在线操场)。查看package.json中的角度依赖项列表。看起来不像您的操场安装正确,如果它显示缺少的依赖项(@角形/核心等)建议清除docker ps -aq | xargs docker rm -f和docker images -aq | xargs docker rmi -f (警告:清除开发环境中的所有码头容器),那么使用curl -sSL https://hyperledger.github.io/composer/install-hlfv1.sh | bash命令安装它(作为一个非特权用户),使用curl -sSL https://hyperledger.github.io/composer/install-hlfv1.sh | bash命令在码头容器中安装操场。
发布于 2017-09-19 11:53:02
这是npm list命令返回的内容。
Calvinde-MacBook-Air:my-network calvinlin007$ npm list -g --depth=0
/usr/local/lib
├── composer-cli@0.12.2
├── composer-playground@0.12.2
├── composer-rest-server@0.12.2
├── generator-hyperledger-composer@0.12.2
├── npm@3.10.10
└── yo@2.0.0
npm ERR! peer dep missing: @angular/core@^4.0.3, required by @ng-bootstrap/ng-bootstrap@1.0.0-beta.2
npm ERR! peer dep missing: @angular/core@>=4.0.0, required by ngx-clipboard@8.0.4
npm ERR! peer dep missing: @angular/common@^4.0.3, required by @ng-bootstrap/ng-bootstrap@1.0.0-beta.2
npm ERR! peer dep missing: @angular/common@>=4.0.0, required by ngx-clipboard@8.0.4
npm ERR! peer dep missing: @angular/forms@^4.0.3, required by @ng-bootstrap/ng-bootstrap@1.0.0-beta.2
npm ERR! peer dep missing: @angular/platform-browser@>=4.0.0, required by ngx-clipboard@8.0.4
npm ERR! peer dep missing: core-js@>=2.4.1, required by ngx-clipboard@8.0.4
npm ERR! peer dep missing: @angular/core@>=2.4.1, required by ngx-window-token@0.0.2
npm ERR! peer dep missing: @angular/common@>=2.4.1, required by ngx-window-token@0.0.2
npm ERR! peer dep missing: @angular/platform-browser@>=2.4.1, required by ngx-window-token@0.0.2
npm ERR! peer dep missing: core-js@>=2.4.1, required by ngx-window-token@0.0.2https://stackoverflow.com/questions/46296159
复制相似问题