I have done npm install ./pathtolocalfolder --save
.
My package.json
has a dependency with name: file: ../pathtolocalfolder
.
How do I import the folder in my project?
npm can't resolve ./node_modules/folder
or folder
.
I have done npm install ./pathtolocalfolder --save
.
My package.json
has a dependency with name: file: ../pathtolocalfolder
.
How do I import the folder in my project?
npm can't resolve ./node_modules/folder
or folder
.
I just tested this and it works fine.
You don't even need to use npm install ./testmodule --save
but your module must have package.json
Main ./package.json with reference to testmodule
{
"name": "npmtest",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"testmodule": "file:testmodule"
}
}
Main ./app.js
var testmod = require('testmodule');
testmod.run();
./testmodule/package.json
{
"name": "testmodule",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
./testmodule/index.js
exports.run = function() { console.log('testmodule'); }