After installing packages e.g. lodash using npm install --save lodash, I am trying to add it to the top of the file.
import _ from 'lodash';
console.log(add(10, 3));
When I start Live Server from VS Code, I get this error. I cannot figure it out how to fix it? Please help me:
Uncaught TypeError: Failed to resolve module specifier "lodash". Relative references must start with either "/", "./", or "../".
I am trying to write the path in different ways, but it did not help me.
npm -vand the project structure, and dependency.json file contents herenode_modulesdirectory? If you are using a rawmoduleand you did not bundle your code yet e.g. WebPack, you will have to change the import to something like:import _ from '../node_modules/lodash'type="module"and I thought I can add lodash without ant bundler. Npm - v =8.19.3: json file include lodash