Reputation: 501
WebStorm gives me a warning of "Unrecognized function or method" on functions like:
I've tried to Enabling the NodeJs core libraries and to install
under Preferences > JavaScript > Libraries
But this has not solved my problem. Does someone knows a solution?
Upvotes: 4
Views: 3890
Reputation: 136
This is possible solution working for me without any issues.
Moving the relative path out of the require() statement as follows.
const PATH = '../models/';
const User = require(PATH + 'user');
Alternatively
Do not import Schema separately.
Just import mongoose like this
const mongoose = require('mongoose');
and use mongoose.Schema
to access Schema
Upvotes: 3
Reputation: 11070
Note that the schema is inserted correctly. Don't forget to check your Schema.
Sample
module.exports = mongoose.model('SampleCollection', SampleSchema);
Upvotes: 0
Reputation: 3391
I don't know the reason but somehow this works:
export
module.exports.User = User; // your model
import
const User = require("../dbSchema/user.js").User;
Upvotes: 2
Reputation: 93768
This issue is tracked as https://youtrack.jetbrains.com/issue/WEB-17099; please see https://youtrack.jetbrains.com/issue/WEB-17099#comment=27-1441265 for possible workaround
Upvotes: 4