我想在ES6中編寫本地npm模塊,我使用babel,npm ...我運行npm install時沒有錯誤,但是當我試圖調用模塊我有這個錯誤:不能導入本地依賴
找不到模塊」 ./lib/daihinmin'
我試圖在幾乎所有我的要求:
var daihinmin=require('./lib/daihinmin');
var daihinmin=require('daihinmin');
var daihinmin=require('daihinmin.js');
的這一切工作,我不明白爲什麼:(
這是我的模塊的package.json:
{
"name": "daihinmin",
"main": "./lib/daihimin.js",
"scripts": {
"compile": "babel --presets es2015 -d lib/ src/",
"prepublish": "npm run compile"
},
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-preset-es2015": "^6.5.0"
}
}
這是我的應用程序的package.json:
{
"name": "MrPresident",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"express": "^4.13.3",
"daihinmin": "./lib/daihinmin"
}
}
screenshot of my application tree
感謝您的幫助:-)
你出口在'daihinmin.js'? –
這是我輸出的錯字(一個noob錯誤)謝謝! – sanghin