找不到名称空间/名称镶边 [英] Cannot find namespace/name chrome

查看:75
本文介绍了找不到名称空间/名称镶边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Angular开发google扩展,但是发现我不能在不生成

I'm trying out the Angular to develop google extension, but found that I can't reference the chrome object without generating the

E:/ChromeExtensions/.../node_modules/chrome-promise/chrome-promise.d.ts(2160,66)中的错误:找不到命名空间"chrome".

ERROR in E:/ChromeExtensions/.../node_modules/chrome-promise/chrome-promise.d.ts (2160,66): Cannot find namespace 'chrome'.

E:/ChromeExtensions/.../src/app/chrome-tabs.servi中的错误 ce.ts(14,7):找不到名称"chrome".

ERROR in E:/ChromeExtensions/.../src/app/chrome-tabs.servi ce.ts (14,7): Cannot find name 'chrome'.

我添加了chrome键入npm install --save @types/chrome,但是它给我的只是键入,但是它不能解决构建错误.

I have added chrome typings npm install --save @types/chrome but all it gave me was, just typings, but it doesnt resolves build errors.

如果这很重要:

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.4.9
node: 6.11.4
os: win32 x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.9
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4

Visual Studio Code 1.17.2

有什么建议吗?

推荐答案

基于

  • 我将@types/chrome添加到package.json
  • 我在文件的顶部添加了/// <reference types="chrome"/>
    1. I added @types/chrome to package.json
    2. I added /// <reference types="chrome"/> to the top of my ts file

    这篇关于找不到名称空间/名称镶边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆