我正在尝试在我的本地(我自己的包)中测试NPM包。我遵循了这个指南:http://rajasekarm.com/publishing-react-component-npm/
我在package.json中有这个:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel statbox.js -o index.js",
"prepublish": "npm run build"
},
我在我的git中提交了这个自定义包,然后做了一个
npm install 'url/url/my_sample.git' --save
但是当我做的时候:
import myModule from 'my_sample'
它说index.js
尚未解决。我该如何解决这个问题?
答案 0 :(得分:0)
如果没有 index.js 文件,我认为你没有内置(因为npm build
会翻译你的 statbox.js < / em>到 index.js )。
所以运行npm build
并重新测试你的包。