我用es6写了一个模块并发布到npm,我想在另一个项目中使用它,所以我输入如下:
import {ActionButton} from 'rcomponents'
Run Code Online (Sandbox Code Playgroud)
但它不起作用:
D:\github\blog\node_modules\rcomponents\src\actionButton.jsx:1
(function (exports, require, module, __filename, __dirname) { import React fro
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .jsx] (D:\github\blog\
node_modules\babel\node_modules\babel-core\lib\api\register\node.js:214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at D:\github\blog\node_modules\rcomponents\src\index.js:3:19
at Object.<anonymous> (D:\github\blog\node_modules\rcomponents\src\index.js:
7:3)
Run Code Online (Sandbox Code Playgroud)
这是我在webpack中的js loader配置:
{ test: /\.jsx?$/, loader: `babel?cacheDirectory=${babelCache}` }
Run Code Online (Sandbox Code Playgroud)
当我尝试导入一个不是来自的模块时node_modules,babel工作得很好.但是导入一个模块node_modules,babel似乎不起作用?
在主题中,_config.yml有两个默认路由:/和/archieves.有可能添加一条路线/about吗?
我尝试添加/about_config.yml,但Cannot GET /about/显示.
我使用child_process.execrun npm init,我可以让它创建package.json,但是创建后,我的stdin似乎仍然打开,我想知道子进程何时完成,所以我也许关闭了stdin,但是我不知道它何时完成。
这是我的代码:
var child = exec('npm init', function (err, stdout, stderr) {
console.log('over');
});
child.stdout.on('data', function(data) {
process.stdout.write(data);
//process.stdin.resume();
});
child.stdout.on('end', function() {
console.log('end out');
});
child.stdout.on('close', function() {
console.log('close out');
});
child.on('exit', function() {
console.log('exit');
});
child.on('close', function() {
console.log('close');
});
child.on('disconnect', function() {
console.log('disconnect');
});
// read stdin and send to child process
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if(chunk !== null) {
child.stdin.write(chunk);
}
});
Run Code Online (Sandbox Code Playgroud)
完成创建package.json后,没有任何事件触发,那么如何在完成后将其关闭?