最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to import in ES6? - Stack Overflow

programmeradmin2浏览0评论

How can I translate var exec = require('child_process').exec; to ES6? I know the following: import exec from 'child_process';

What I don't know is how to add the .exec at the end to the ES6 syntax.

How can I translate var exec = require('child_process').exec; to ES6? I know the following: import exec from 'child_process';

What I don't know is how to add the .exec at the end to the ES6 syntax.

Share Improve this question asked Feb 10, 2018 at 18:52 fardinfardin 1,4774 gold badges22 silver badges29 bronze badges 1
  • 1 Try import { exec } from 'child_process' – elclanrs Commented Feb 10, 2018 at 18:55
Add a ment  | 

1 Answer 1

Reset to default 7

How can I translate var exec = require('child_process').exec; to ES6?

You do:

import { exec } from 'child_process';

I know the following: import exec from 'child_process';

That's actually wrong, it is as I've done above. More on import here.

Otherwise, is simply:

import child_process from 'child_process';
const exec = child_process.exec;

You CANNOT do anything like:

import exec from 'child_process'.exec;
发布评论

评论列表(0)

  1. 暂无评论