Import from node_modules not recognized in es6 modules in browser

前端 未结 3 1279
野性不改
野性不改 2020-12-16 20:13

I\'m trying to use lodash in my web application. I have installed lodash using npm in my local project.

I plan on using the ES6 modules in my code.

Here is

3条回答
  •  青春惊慌失措
    2020-12-16 20:20

    If you don't wish to use any bundling tools, you will need to provide a path to the lodash folder within node_modules, relative to the JavaScript file that you have the import statement in.

    If you do not wish to use a bundler, it would also be worthwhile importing from the specific file, the function you need. For example:

    import _each from '../node_modules/lodash/each'
    

提交回复
热议问题