使用 Angular-cli ,我使用的是名为
的软件包当我在开发模式ng serve
中构建时,我没有收到错误,应用程序正常工作。但是,当我部署到Heroku或运行ng build --prod
时,我收到以下错误:
ERROR in vendor.e51673ef8f2bd683eebc.bundle.js from UglifyJs
Unexpected token: name (LB100) [vendor.e51673ef8f2bd683eebc.bundle.js:16119,6]
LB100似乎是此软件包的main.js文件中所需的javascript文件。如果我发表评论,因为我没有在我的应用程序中使用它,另一个人最终会出现错误。
以下是LB100.js文件的示例,也许有人可以看到一些在当前'ugilifyjs'中无效的语法。如果您确实看到了问题,我该如何解决?
以下LB100.js通过require语句加载到Tplink.js中:
var LB100 = require("./lb100.js")
var TPLinkDevice = require('./device.js');
// Should work for LB100, LB110 & LB120
class LB100 extends TPLinkDevice {
constructor(tpLink, deviceInfo){
super(tpLink, deviceInfo);
}
async transition_light_state(on_off, brightness){
// on_off: 1 for On, 0 for Off
// brightness: 0-100
return await super.tplink_request( {
"smartlife.iot.smartbulb.lightingservice": {
"transition_light_state": { "on_off": on_off, "brightness": brightness } }
}
)
}
}
module.exports = LB100;
经过一些研究,它看起来是一个错误的一些语法,而包使用ES5不能很好地编译。我将'TSConfig'中的目标更改为ES6,但它仍然无法正常工作,但却出现了与AppModule相关的其他错误。
{
"compileOnSave": false,
"compilerOptions": {
"types": [
"node"
],
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"es6",
"es2015"
]
}
}
正如你所看到的,我也放入了Libs,因为这有助于其他人。但是,到目前为止我没有取得任何进展。我使用的是最新版本的Node。
{
"name": "temp-sensor",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot -prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/cli": "1.3.2",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/compiler-cli": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.101",
"angularfire2": "5.0.0-rc.3",
"bootstrap": "4.0.0-beta.2",
"codelyzer": "~3.1.1",
"core-js": "^2.4.1",
"firebase": "4.6.0",
"font-awesome": "^4.7.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"jquery": "^3.2.1",
"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",
"popper": "^1.0.1",
"protractor": "~5.1.2",
"rxjs": "^5.4.2",
"tplink-cloud-api": "^0.2.0",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"uglify": "^0.1.5",
"uglifyjs-webpack-plugin": "^1.2.0",
"zone.js": "^0.8.14",
"typescript": "^2.7.2"
},
"engines": {
"node": "9.5.0",
"npm": "5.6.0"
},
"devDependencies": {
}
}
我在服务中加载此包:
declare var require: any;
const TPLink = require('../../../node_modules/tplink-cloud-api');
我还运行了NPM更新...
此时我完全迷失了。任何帮助表示赞赏