2017-11-27 11 views
1

角度モジュールを別のnpmモジュールとしてエクスポートしようとしています。ng-packagrがパッケージをビルドできません。予期しないトークンエラー:予期しないトークンrollup.js

だから私は "packagr"(NPMでそれをやろうとしている:すべては "FESM15にコンパイル" まで良い起こっている "NG-packagr -p NG-package.json"

私は下にログを貼り付けます。

"compileOnSave": false, 
    "compilerOptions": { 
    "outDir": "./dist/out-tsc", 
    "sourceMap": true, 
    "declaration": false, 
    "moduleResolution": "node", 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "target": "es5", 
    "typeRoots": [ 
     "node_modules/@types" 
    ], 
    "lib": [ 
     "es2017", 
     "dom" 
    ] 
    } 
}

そして、私のpackage.json以下tsconfig.json


ng-packagr -p ng-package.json 

Building Angular library 
Generating bundle for widget 
Cleaning bundle build directory 
Processing assets 
Running ngc 
Compiling to FESM15 
'fs' is imported by node_modules/jsdom/lib/jsdom.js, but could not be resolved – treating it as an external dependency 
'path' is imported by node_modules/jsdom/lib/jsdom.js, but could not be resolved – treating it as an external dependency 
'net' is imported by node_modules/tough-cookie/lib/cookie.js, but could not be resolved – treating it as an external dependency 
preferring built-in module 'url' over local alternative at '/home/test/codeProjects/widget/node_modules/url/url.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'url' over local alternative at '/home/test/codeProjects/widget/node_modules/url/url.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
'url' is imported by node_modules/tough-cookie/lib/cookie.js, but could not be resolved – treating it as an external dependency 
preferring built-in module 'punycode' over local alternative at '/home/test/codeProjects/widget/node_modules/punycode/punycode.js',pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'punycode' over local alternative at '/home/test/codeProjects/widget/node_modules/punycode/punycode.js',pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
'punycode' is imported by node_modules/tough-cookie/lib/pubsuffix.js, but could not be resolved – treating it as an external dependency 
preferring built-in module 'punycode' over local alternative at '/home/test/codeProjects/widget/node_modules/punycode/punycode.js',pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'punycode' over local alternative at '/home/test/codeProjects/widget/node_modules/punycode/punycode.js',pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'punycode' over local alternative at '/home/test/codeProjects/widget/node_modules/punycode/punycode.js',pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
'punycode' is imported by commonjs-external:punycode, but could not be resolved – treating it as an external dependency 
preferring built-in module 'util' over local alternative at '/home/test/codeProjects/widget/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'util' over local alternative at '/home/test/codeProjects/widget/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
'util' is imported by node_modules/tough-cookie/lib/memstore.js, but could not be resolved – treating it as an external dependency 
preferring built-in module 'util' over local alternative at '/home/test/codeProjects/widget/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'util' over local alternative at '/home/test/codeProjects/widget/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
preferring built-in module 'util' over local alternative at '/home/test/codeProjects/widget/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning 
'util' is imported by commonjs-external:util, but could not be resolved – treating it as an external dependency 

BUILD ERROR 
Unexpected token 
Error: Unexpected token 
    at error (/home/test/codeProjects/widget/node_modules/rollup/dist/rollup.js:185:14) 
    at Module.error (/home/test/codeProjects/widget/node_modules/rollup/dist/rollup.js:16526:3) 
    at tryParse (/home/test/codeProjects/widget/node_modules/rollup/dist/rollup.js:16220:10) 
    at new Module (/home/test/codeProjects/widget/node_modules/rollup/dist/rollup.js:16264:15) 
    at load.catch.then.then.then.source (/home/test/codeProjects/widget/node_modules/rollup/dist/rollup.js:18189:20) 
    at 

npm ERR! code ELIFECYCLE 
npm ERR! errno 111 
npm ERR! [email protected] packagr: `ng-packagr -p ng-package.json` 
npm ERR! Exit status 111 
npm ERR! 
npm ERR! Failed at the [email protected] packagr script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 


{ 
    "name": "widget", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e", 
    "packagr": "ng-packagr -p ng-package.json", 
    "prepublish": "tsc" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/animations": "^5.0.0", 
    "@angular/common": "^5.0.0", 
    "@angular/compiler": "^5.0.0", 
    "@angular/core": "^5.0.0", 
    "@angular/forms": "^5.0.0", 
    "@angular/http": "^5.0.0", 
    "@angular/platform-browser": "^5.0.0", 
    "@angular/platform-browser-dynamic": "^5.0.0", 
    "@angular/router": "^5.0.0", 
    "core-js": "^2.4.1", 
    "fabric": "^2.0.0-rc.3", 
    "rxjs": "^5.5.2", 
    "zone.js": "^0.8.14" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.5.4", 
    "@angular/compiler-cli": "^5.0.0", 
    "@angular/language-service": "^5.0.0", 
    "@types/jasmine": "~2.5.53", 
    "@types/jasminewd2": "~2.0.2", 
    "@types/node": "~6.0.60", 
    "codelyzer": "^4.0.1", 
    "jasmine-core": "~2.6.2", 
    "jasmine-spec-reporter": "~4.1.0", 
    "karma": "~1.7.0", 
    "karma-chrome-launcher": "~2.1.1", 
    "karma-cli": "~1.0.1", 
    "karma-coverage-istanbul-reporter": "^1.2.1", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "ng-packagr": "^1.6.0", 
    "protractor": "~5.1.2", 
    "ts-node": "~3.2.0", 
    "tslint": "~5.7.0", 
    "typescript": "~2.4.2" 
    }, 

} 

なぜパッケージがビルドしたくないのでしょうか。モジュールを正常にビルドする(npmをビルドする)とき、あるいはプロダクション(npmをビルドする--prod)の場合でも、すべて正常に動作するようです。

ありがとうございました。

+0

あなたはすでに解決策を見つけましたか?現在、同じ問題が発生しています。 – Nicholas

答えて

0

私は同じ問題がありました。エラーに記載されているモジュールをng-package.jsonの外部リストに追加して解決しました。つまり:

{ 
    "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 
    "lib": { 
    "entryFile": "public_api.ts", 
    "externals": { 
     "jsdom": "jsdom", 
     "tough-cookie": "tough-cookie" 
     // etc (or maybe you can localize the module that is using 
     // them and use that module instead) 
    } 
    } 
} 
関連する問題