I published my own npm module but it cannot find from my sample script.
This is my module
https://www.npmjs.com/package/kong-hmac
https://github.com/y-zono/kong-hmac-js
What I did.
$ mkdir /tmp/sample-myjs
$ cd /tmp/sample-myjs/
$ touch package.json
$ echo "{}" > package.json
$ npm install --save kong-hmac
$ npm install --save-dev babel-cli
$ npm install --save-dev babel-preset-es2015
$ touch test.js
$ echo 'const hmac = require("kong-hmac");' > test.js
$ babel-node --presets es2015 test.js
module.js:327
throw err;
^
Error: Cannot find module 'kong-hmac'
Any ideas? My module is written in ES2015.
Inside your node_modules
look for the package kong-hmac
you find lib
folder not src
and in the package.json
of kong-hmac change "main": "src/index.js"
to "main": "lib/index.js"
.
I guess, while publish a package npm structures the program this way
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.