Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

ipfs-core-types is incorrectly built on npm #3976

Closed
siepra opened this issue Dec 14, 2021 · 17 comments · Fixed by #4056
Closed

ipfs-core-types is incorrectly built on npm #3976

siepra opened this issue Dec 14, 2021 · 17 comments · Fixed by #4056
Assignees
Labels
kind/stale need/author-input Needs input from the original author

Comments

@siepra
Copy link

siepra commented Dec 14, 2021

  • Version:
    ipfs-core-types@0.8.4

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 siepra added the need/triage Needs initial labeling and prioritization label Dec 14, 2021
@welcome
Copy link

welcome bot commented Dec 14, 2021

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.

@siepra
Copy link
Author

siepra commented Dec 14, 2021

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 ;)

@achingbrain
Copy link
Member

achingbrain commented Dec 15, 2021

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?

@siepra
Copy link
Author

siepra commented Dec 15, 2021

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 native-fetch@3.0.0 requires a peer of node-fetch@* but none is installed. You must install peer dependencies yourself.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

+ ipfs-core-types@0.8.4
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.

@flynnhou
Copy link

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

@flynnhou
Copy link

flynnhou commented Jan 11, 2022

So I made an experiment with a fork (flynnhou@796ba40) 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",
  }
}

@siepra
Copy link
Author

siepra commented Feb 23, 2022

@achingbrain any thoughts on that?

@BigLep BigLep added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Mar 1, 2022
@BigLep
Copy link
Contributor

BigLep commented Mar 1, 2022

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

achingbrain added a commit that referenced this issue Mar 1, 2022
When using `copyfiles` globstars need to be quoted on a Mac otherwise
they don't work

See the README at https://www.npmjs.com/package/copyfiles

Fixes #3976
achingbrain added a commit that referenced this issue Mar 1, 2022
When using `copyfiles` globstars need to be quoted on a Mac otherwise they don't work

See the README at https://www.npmjs.com/package/copyfiles

Fixes #3976
@achingbrain
Copy link
Member

@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

@BigLep BigLep reopened this Mar 1, 2022
@siepra
Copy link
Author

siepra commented Mar 16, 2022

@achingbrain I confirm it worked

@BigLep BigLep removed the need/author-input Needs input from the original author label Mar 25, 2022
@BigLep
Copy link
Contributor

BigLep commented Mar 25, 2022

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

@BigLep BigLep added this to In Progress in Maintenance Priorities - JS Apr 1, 2022
@lidel lidel moved this from In Progress to In Review in Maintenance Priorities - JS Apr 1, 2022
@achingbrain
Copy link
Member

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

@lidel lidel added the need/author-input Needs input from the original author label Apr 8, 2022
@lidel lidel closed this as completed Apr 22, 2022
Maintenance Priorities - JS automation moved this from In Review to Done Apr 22, 2022
@tomjohnhall
Copy link

tomjohnhall commented Jul 11, 2022

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!

@teacoat
Copy link

teacoat commented Jul 19, 2022

I am getting a similar issue to @tomjohnhall,

image

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

@BigLep BigLep reopened this Jul 19, 2022
@BigLep
Copy link
Contributor

BigLep commented Jul 22, 2022

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.

@github-actions
Copy link
Contributor

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
Copy link
Contributor

github-actions bot commented Aug 5, 2022

This issue was closed because it is missing author input.

@github-actions github-actions bot closed this as completed Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/stale need/author-input Needs input from the original author
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

7 participants