Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module 'files-from-path' #36

Open
talentlessguy opened this issue Jan 9, 2024 · 5 comments
Open

Comments

@talentlessguy
Copy link

Seems like package.json is incorrectly formatted

Could not find a declaration file for module 'files-from-path'. '/home/v1rtl/Coding/stauro/minicar/node_modules/files-from-path/esm/src/index.js' implicitly has an 'any' type.
  There are types at '/home/v1rtl/Coding/stauro/minicar/node_modules/files-from-path/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'files-from-path' library may need to update its package.json or typings.

exports must also have a types field:

https://github.com/web3-storage/files-from-path/blob/2398128eae1bf9e1963c63e9488ee0c81ba07487/package.json#L27-L32

@mpoletiek
Copy link

Similar problem:

$ npm run build

> [email protected] build
> next build

   Linting and checking validity of types  ...Failed to compile.

./pages/api/ipfs.tsx:15:32
Type error: Could not find a declaration file for module 'files-from-path'. '/home/mwa/www/mwa-nft-0/node_modules/files-from-path/esm/src/index.js' implicitly has an 'any' type.
  There are types at '/home/mwa/www/mwa-nft-0/node_modules/files-from-path/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'files-from-path' library may need to update its package.json or typings.

  13 | // Web3 Storage
  14 | import { create } from '@web3-storage/w3up-client';
> 15 | import { filesFromPaths } from 'files-from-path';
     |                                ^
  16 | const client = await create();
  17 | await client.login('[email protected]');
  18 | await client.setCurrentSpace('did:key:z6MkryKW8fcfGm8hYqKsLVi456VKWLhcLuKfNe91XMunfKvF');




$ npm install @types/files-from-path
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2ffiles-from-path - Not found
npm ERR! 404 
npm ERR! 404  '@types/files-from-path@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /home/mwa/.npm/_logs/2024-01-15T06_08_01_228Z-debug-0.log

@magror
Copy link

magror commented Jan 18, 2024

This is also happening to me.

I am attempting to use this in a Docker Image with Typescript.

My package.json has "type": "module" and my tsconfig.json has "module": "NodeNext" to ensure compatibility with w3up

I was able to get past this compilation error by doing ts-ignore
// @ts-ignore *newline* import { getFilesFromPath } from 'files-from-path'
However, in that scenario I get the runtime error:
ERROR Uncaught Exception {"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: The requested module 'files-from-path' does not provide an export named 'getFilesFromPath'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: The requested module 'files-from-path' does not provide an export named 'getFilesFromPath'"," at _loadUserApp (file:///var/runtime/index.mjs:1084:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]}

EDIT: it seems that getFilesFromPath was changed to filesFromPaths. I no longer get the runtime error with the updated function name.

@magror
Copy link

magror commented Jan 18, 2024

@mpoletiek @talentlessguy I was able to solve this temporarily by adding // @ts-ignore above my import statement. It seems that this dependency does not have typescript set up properly. (there is a types folder but clearly it isn't connected or something)

@mpoletiek
Copy link

mpoletiek commented Jan 19, 2024 via email

@mpoletiek
Copy link

@magror

Thanks, that worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants