Angular 2 npm开始问题

时间:2017-07-13 06:15:20

标签: angular npm package.json

当我尝试运行命令 npm start 时,会出现如下错误:

enter image description here

我的 package.json 文件是: -

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "dist"
  }
}

我的 tsconfig.json 文件是: -

var payLoad= JSON.stringify(ItemJSON);                                                                      
var xmlhttp = new XMLHttpRequest();                                                                 
xmlhttp.addEventListener("readystatechange", function () {                                          
  if (xmlhttp.readyState < 4){                                                                      
    }                                                                                               
    else if (xmlhttp.readyState === 4) {                                                            
      if (xmlhttp.status == 200 && xmlhttp.status < 300){                                         
            console.log("Success",xmlhttp.responseText);                                            
        }                                                                                          
    }else{                                                                                          
        alert("Error!! \\n There was an error while saving. Please retry again later.");        
                }                                                                                           
        });                                                                                                 
        xmlhttp.open("POST", URL, false);                                                                   
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");                       
        xmlhttp.send(payLoad);  
}

请告诉我需要更改的内容以及如何在服务器上部署项目?

2 个答案:

答案 0 :(得分:0)

您只需添加:

"noImplicitAny": "false"

compilerOptions中的tsconfig.json,它应解决此问题。

答案 1 :(得分:0)

在我的情况下,我做了

In package.json file
When I "npm start" the application didn't run, then I changed it to
"start": "concurrently "npm run tsc:w" "npm run lite" ", in package.json
then the application ran without errors.

希望有所帮助