ฉันต้องการรวมไลบรารี่ของเชลล์ js เข้ากับ typescript เชิงมุม 2 ฉันได้รวมไฟล์ shelljs.d.ts ไว้ในไลบรารี node_modules/shelljs ของฉันแล้ว
package.json ของฉัน
"name": "myproj1",
"description": "myproj1: A project",
"typings": {
"shelljs": {
"definitions": "node_modules/shelljs/shelljs.d.ts",
"source": "node_modules/shelljs/global.js"
}
},
webpack.config.js ของฉัน
var path = require('path');
module.exports = {
entry: './app/web/boot.ts',
output: {
path: path.resolve(__dirname, "js"),
filename: "bundle.js"
},
resolve: {
extensions:['','.js','.ts']
},
module:{
loaders: [{
test: /\.ts/,
loaders: ['ts-loader'],
exclude: /node_modules/
}]
},
target: 'node'
};
ตัวเลือกคอมไพเลอร์ package.json ของฉัน:
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
ไฟล์ TS ของฉัน:
import child = require("shelljs");
somefun(){
child.exec('node --version',(code, stdout, stderr)=>{
console.log('Exit code:', code);
console.log('Program output:', stdout);
console.log('Program stderr:', stderr);
});
}
ฉันได้รับข้อผิดพลาด "ไม่พบโมดูล 'shelljs'" โปรดช่วยฉันรวมห้องสมุดไว้ในโครงการของฉัน
shell.js
ทำงานอย่างไร แต่ลองlet shell = require('shelljs/global'); shell.exec(...
- person tchelidze   schedule 28.04.2016