我刚刚开始使用ionic2:
$ npm install -g ionic cordova
$ ionic start cutePuppyPics --v2
$ cd cutePuppyPics
$ ionic serve
我有这个错误:无法找到模块'reflect-metadata'
$ ionic info
ordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v7.7.2
Xcode version: Not installed
我也尝试npm update -g
,但不行
npm -v
:2.15.11
ionic -v
2.2.1
答案 0 :(得分:5)
打开项目文件夹 打开Package.json并添加" reflect-metadata":" ^ 0.1.3",
答案 1 :(得分:2)
在Ionic项目中,打开:
的package.json
在其中添加:
package org.sonar.template.java.checks;
import com.google.common.collect.ImmutableList;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.plugins.java.api.semantic.Symbol;
import org.sonar.plugins.java.api.semantic.Symbol.TypeSymbol;
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
import org.sonar.plugins.java.api.tree.*;
import org.sonar.plugins.java.api.tree.Tree.Kind;
import java.util.List;
@Rule(
key = "SharedPreferencesRule",
name = "Utilização de SharedPreferences no código",
description = "Para cada utilização de SharedPreferences, é feito um alerta para revisar o que está sendo armazenado.",
priority = Priority.CRITICAL,
tags = {"attention point", "security"})
public class SharedPreferencesCheck extends IssuableSubscriptionVisitor {
@Override
public List<Kind> nodesToVisit() {
return ImmutableList.of(Kind.METHOD_INVOCATION);
}
@Override
public void visitNode(Tree tree){
System.out.println("====================== Kind Finded ======================");
MethodInvocationTree kindTree = (MethodInvocationTree) tree;
Symbol symbol = (Symbol) kindTree.symbol();
TypeSymbol classe = symbol.owner().enclosingClass();
System.out.println("Name >>>>>>>>>>>>> " + symbol.name());
System.out.println("Enclosing >>>>>>>>>>>>> " + classe);
if (classe != null && classe.equals("SharedPreferences")){
reportIssue(kindTree.firstToken(), "SharedPreferences sendo utilizado no código. Analisar!!");
}
}
}
然后在控制台上运行:
"reflect-metadata": "^0.1.3",
然后运行:npm install
准备好运行npm rebuild
以查看您的应用;)
答案 2 :(得分:0)
我删除了 /dist 文件夹,然后就可以了