2

Creating a simple package.json

yarn init

{
  "name": "freedraw",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT"
}

Adding leaflet-freedraw dependency:

yarn add leaflet-freedraw

{
  "name": "freedraw",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "leaflet-freedraw": "^2.13.0"
  }
}

The installed node module only contains this:

/dist
package.json
LICENSE
README.md

There sould also be the source folder installed:

/src

The devs from freedraw say the /src folder should also be there.

I'm using a lot of packages and I get the /src folder everywhere except here. Same happens with npm.

RobC
  • 22,977
  • 20
  • 73
  • 80
Mike
  • 5,416
  • 4
  • 40
  • 73
  • 1
    You're not asking a question. I guess you should make your complaints at https://github.com/Wildhoney/Leaflet.FreeDraw/issues , and/or send a pull request regarding https://github.com/Wildhoney/Leaflet.FreeDraw/commit/3b82125994e9676ea018d67bf04a679934bbf5e8 . – IvanSanchez Jun 25 '20 at 15:06
  • I’m voting to close this question because it is not a question. – IvanSanchez Jun 25 '20 at 15:07
  • The question was already asked at freedraw like I wrote. The answer was it should work. So I'm asking here again. – Mike Jun 25 '20 at 15:10

2 Answers2

2

There sould also be the source folder installed

There is no obligation for an author to also publish the src on npm.

As pointed out by Ivan, it looks like the author did configure their package to publish only files in the "dist" folder: (that might be a mistake on their part)

Extract from package.json:

{
  "files": [
    "dist"
  ],
}

https://github.com/Wildhoney/Leaflet.FreeDraw/commit/3b82125994e9676ea018d67bf04a679934bbf5e8

npm doc for package.json "files" field:

The optional files field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to .gitignore, but reversed: including a file, directory, or glob pattern (*, **/*, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to ["*"], which means it will include all files.

https://docs.npmjs.com/configuring-npm/package-json.html#files

ghybs
  • 47,565
  • 6
  • 74
  • 99
  • OK, thanks. I was wondering because he said he tested it and could not find a problem. I will try to let him change this. – Mike Jun 25 '20 at 18:50
1

We are facing a similar issue, and are missing the src/ sub-directory when running a global install of an NPM package from our private NPM registry.

There is nothing referenced in the .npmignore or .gitignore files, and we are even explicitly referencing the src/ sub-directory in files block in the package.json:

{
...
  "main": "./bin/cli.js",
  "bin": {
    "app_name": "./bin/cli.js"
  },
  "scripts": {
    "start": "node ./bin/cli.js"
  },
  "files": [
    "bin",
    "test",
    "src",
    "package.json"
  ],
...
}

Interestingly the install also fails to install the test sub-directory, and moving the entry point to the src/ sub-directory results in it failing to install at all with the following error:

ENOENT: no such file or directory, chmod '...node_modules/@private_registry/app_name/src/cli.js
Brom558
  • 185
  • 1
  • 4