js-ipfs icon indicating copy to clipboard operation
js-ipfs copied to clipboard

ipfs-core-types is incorrectly built on npm

Open siepra opened this issue 4 years ago • 17 comments

Severity:

High

Description:

When installed with npm, package is missing "dist" folder. It works well if built and linked locally

Zrzut ekranu 2021-12-14 o 12 34 07 Zrzut ekranu 2021-12-14 o 12 35 19

Steps to reproduce the error:

Use ipfs-core-types package installed with npm

siepra avatar Dec 14 '21 11:12 siepra

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

welcome[bot] avatar Dec 14 '21 11:12 welcome[bot]

I've added temporary workaround in my project but I'm looking forward to find that problem fixed as it holds me back a little bit ;)

siepra avatar Dec 14 '21 11:12 siepra

ipfs-core-types doesn't have a dist directory on publish, the dist directory created during build is the published artifact.

This sounds like the typesVersions field needs an additional wildcard - how do I replicate the problem with your project?

achingbrain avatar Dec 15 '21 10:12 achingbrain

Actually I'm able to reproduce this outside of my project. I'm doing this like this:

apple@MacBook-Pro-Apple Application Support % cd /tmp
apple@MacBook-Pro-Apple /tmp % mkdir test
apple@MacBook-Pro-Apple /tmp % cd test  
apple@MacBook-Pro-Apple test % npm init 
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (test) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /private/tmp/test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) yes
apple@MacBook-Pro-Apple test % npm i --save ipfs-core-types
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of node-fetch@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 16 packages from 57 contributors and audited 16 packages in 5.703s
found 0 vulnerabilities

apple@MacBook-Pro-Apple test % cd node_modules/ipfs-core-types/src 
apple@MacBook-Pro-Apple src % find .
.
./swarm
./swarm/index.ts
./pin
./pin/index.ts
./diag
./diag/index.ts
./bootstrap
./bootstrap/index.ts
./root.ts
./config
./config/index.ts
./bitswap
./bitswap/index.ts
./dht
./dht/index.ts
./dag
./dag/index.ts
./utils.ts
./key
./key/index.ts
./object
./object/index.ts
./refs
./refs/index.ts
./files
./files/index.ts
./pubsub
./pubsub/index.ts
./log
./log/index.ts
./index.ts
./name
./name/index.ts
./repo
./repo/index.ts
./stats
./stats/index.ts
./block
./block/index.ts
apple@MacBook-Pro-Apple src % 

As you can see, for example file src/config/profile/index.ts is not included in the installed directory.

Interestingly I tried building the package locally from checkout using:

npm run build
npm pack

In this case the resulting package had all the files in src. So I'm not really sure what went wrong, it seems that building scripts are fine, just this particular build in npm is broken.

siepra avatar Dec 15 '21 13:12 siepra

I'm encountering the same problem! I hope the team has some time to fix this soon!

flynnhou avatar Jan 11 '22 18:01 flynnhou

So I made an experiment with a fork (https://github.com/flynnhou/js-ipfs/commit/796ba402a96f5378a554d9d983a943c68c006bbc) for my project too. I'm not an expert on TypeScript and the copyfile tool, and so I'm not sure if my attempt is clean. Basically, installing ipfs-core comes with ipfs-core-types, where the package contained an incomplete structure of the original src; only index.* were copied but the nested folders weren't.

TL;DR

Removing the problematic built node_modules/ipfs-core-types/src will solve the issue. Just like what @siepra mentioned in the above linked issue!

Ad Hoc Workaround

Since I didn't spend too much time getting familiar with js-ipfs project development, I didn't fully get how to install my fork repo as an alternative in the entire build flow. My ugly ad hoc workaround is that in package.json (see below), install "ipfs-core": "^0.13.0" as usual. Meanwhile, add a postinstall npm script to remove the src folder: "postinstall": "rm -rf node_modules/ipfs-core-types/src". At least it works for my project for now!

{
  "scripts": {
    "postinstall": "rm -rf node_modules/ipfs-core-types/src"
  },
  "dependencies": {
    "ipfs-core": "^0.13.0",
  }
}

flynnhou avatar Jan 11 '22 22:01 flynnhou

@achingbrain any thoughts on that?

siepra avatar Feb 23 '22 11:02 siepra

Maintainers will check in on this during 2022-03-04 triage.

BigLep avatar Mar 01 '22 01:03 BigLep

@siepra @flynnhou I've pushed a fix for the missing files, could you please try with the rc and let me know if it resolves the problem for you?

npm i --save ipfs-core-types@next npm i --save ipfs-core@next etc

achingbrain avatar Mar 01 '22 11:03 achingbrain

@achingbrain I confirm it worked

siepra avatar Mar 16 '22 11:03 siepra

2022-03-25 conversation: we're going to close this issue once the build is passing.

BigLep avatar Mar 25 '22 14:03 BigLep

This should be resolved in the latest patch release, no need to use @latest any more. Please can you give it another try?

achingbrain avatar Apr 05 '22 15:04 achingbrain

Hi, I'm getting a wall of these Cannot find module 'ipfs-core-types/dist/src' building using:

"ipfs-core": "^0.15.4"
"ipfs-core-types": "^0.11.1"

I've tried removing node modules and starting afresh, also with @next patches too, and hit the same issue. I did have ipfs-core@0. 14 running okay previously but was hoping to upgrade to latest to see if that would solve a separate issue I was getting when adding files.

Is this definitely fixed or are there still steps needed to manage these typescript warnings?

Thanks for any help!

tomjohnhall avatar Jul 11 '22 16:07 tomjohnhall

I am getting a similar issue to @tomjohnhall,

image

"ipfs-core": "^0.15.4", "ipfs-core-types": "^0.11.1",

teacoat avatar Jul 19 '22 04:07 teacoat

2022-07-22 update: we will release a new version of js-libp2p the week of 2022-07-25 and will bubble it up to js-ipfs and do a release. We expect the next js-ipfs release to address this.

BigLep avatar Jul 22 '22 14:07 BigLep

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

github-actions[bot] avatar Jul 29 '22 00:07 github-actions[bot]

This issue was closed because it is missing author input.

github-actions[bot] avatar Aug 05 '22 00:08 github-actions[bot]