简体   繁体   中英

How to import node module in Angular?

I'm developing an Angular app. For some reason I want to use querystring.escape() . I wrote import { escape } from 'querystring' , but I got querystring.escape is not a function error. How can I import a node module in typescript?

You are destructuring querystring trying to get the escape property, but then you want to call querystring.escape() which you haven't imported.

What you want to do is this:

import * as querystring from 'querystring';

or

import querystring from 'querystring'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM