NPM doesn't install module dependencies

前端 未结 16 1770
深忆病人
深忆病人 2020-12-02 06:39

This is my package.json for the module that I\'m including in the parent project:

{
  \"version\": \"0.0.1\",
  \"name\": \"module-name\",
  \"d         


        
16条回答
  •  半阙折子戏
    2020-12-02 06:51

    I suspect you're facing the issue where your package.json file is not in the same directory as your Gruntfile.js. When you run your grunt xxx commands, you get error an message like:

    Local Npm module "xxx" not found. Is it installed?
    

    For now, the solution is:

    • Create package.json in the same directory as Gruntfile.js
    • Define the modules required by your grunt project
    • Execute npm install to load them locally
    • Now the required grunt command should work.

    IMHO, it is sad that we cannot have grunt resolve modules loaded from a parent npm module (i.e. package.json in a parent directory within the same project). The discussion here seems to indicate that it was done to avoid loading "global" modules but I think what we want is loading from "my project" modules instead.

提交回复
热议问题