角度无法导入库
我安装从https://www.npmjs.com/package/js-beautify角度无法导入库
通过npm install js-beautify --save
再加入进口JS-美化我app.component.ts
单证说要
import jsbeautifier
但它需要引号,所以我使用
import 'jsbeautifier'
但在那之后,当我试图使用它我收到错误:
Failed to compile.
./src/app/app.component.ts
Module not found: Error: Can't resolve 'jsbeautifier' in '/home/oscar/IdeaProjects/lodashteatcherv4/src/frontend/src/app'
@ ./src/app/app.component.ts 14:0-22
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
我也试过这种进口
import '../../node_modules/js-beautify/js/lib/beautify.js'
我采用了棱角分明的CLI 2/4
你在混淆文档import jsbeautifier
的Python指令。为了导入此美化在JavaScript(客户端或的NodeJS),你需要做的是这样的:
import { js_beautify } from 'js-beautify'
不过,我怀疑你真的想这样做,这样一来,代码美化可能不应该成为其中的一部分你app.component.ts
。
您可能需要输入以下命令: 'npm我@ types/js-beautify' –
伙计,它的工作,但我想知道为什么我能够做到: import'rxjs/add/operator/map'; import'hammerjs'; import'prismjs'; 在我的app.component.ts? –
你可以这样做,因为这些模块存在。没有可以导入的“jsbeautifier”模块,因此无法使用。 – dfsq
[使用Angular-CLI安装第三方应用程序](https://stackoverflow.com/questions/42031389/installing-3rd-party-applications-with-angular-cli) – jonrsharpe