无法解析模块index.js npm包
问题描述:
我想在我的本地(我自己的包)中测试一个NPM包。我遵循这个指南:http://rajasekarm.com/publishing-react-component-npm/无法解析模块index.js 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
是未解决的。我该如何解决这个问题?
答
如果没有index.js文件,我想你没有内置(因为npm build
将会把你的statbox.js到index.js)。
因此运行npm build
并重新测试您的软件包。