I am missing something fairly basic at the beginning of my exploration into Node.js. I am trying to build a little app using passportjs authentication.
I have the following line in my app.ts
:
import passport = require("passport");
and the following im my package.json:
{
"name": "ftct",
"version": "0.0.0",
"description": "ftct",
"main": "app.js",
"author":
{
"name": "Mark.Norgate",
"email": ""
},
"dependencies":
{
"express": "3.4.4",
"jade": "*",
"passport": "^0.3.2",
"stylus": "*"
}
}
However, Visual Studio 2015 complains:
Build: Cannot find module 'passport'.
What am I missing? I have read a little of the documentation for passportjs but nothing so far that indicates what the problem might be.
Adding a new module to your package.json won't actually include the dependency in the repository. You'll need to either run npm install
after adding dependencies to package.json, or you can install packages using something like npm install <package name>
. In this case, you'd want npm install passport
.
npm install
will download the source from npm and put it into the ./node_modules directory.
npm install documentation
Change:
import passport = require("passport");
to:
var passport = require("passport");
I had a similar issue where passport was installed and properly saved in package.json but was still getting an error.
My issue was that within package.json there were the lines
"engines": {
"node": ">=6.9.1"
},
I compared my package.json to other examples online and then removed that line and it worked.
Remove node_modules, remove package-lock.json, then run npm install and then run npm install --save passport.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With