Keystone: Error: Cannot find module '@keystonejs/file-adapters'

Created on 13 Dec 2019  路  1Comment  路  Source: keystonejs/keystone

Bug report

Describe the bug

I want to test the file upload function according to the document https://www.keystonejs.com/keystonejs/file-adapters/

but I got the error:

Error: Cannot find module '@keystonejs/file-adapters'
  at executeDefaultServer (/Users/william/B/testAdin/my-app/node_modules/@keystonejs/keystone/bin/utils.js:96:64) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [

The problem is here:

const { File } = require('@keystonejs/fields');
const { LocalFileAdapter } = require('@keystonejs/file-adapters'); 

but i do see the file-adapters denefined in node_modules.

package.json

...
"scripts": {
    "dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
    "build": "cross-env NODE_ENV=production keystone build",
    "start": "cross-env NODE_ENV=production keystone start"
  },
  "dependencies": {
    "@keystonejs/adapter-mongoose": "^5.1.3",
    "@keystonejs/app-admin-ui": "^5.3.0",
    "@keystonejs/app-graphql": "^5.0.1",
    "@keystonejs/auth-password": "^5.0.1",
    "@keystonejs/fields": "^6.0.0",
    "@keystonejs/keystone": "^5.3.0",
    "cross-env": "^5.2.0"
  }

To Reproduce

  1. npm init keystone-app my-app
  2. add const { LocalFileAdapter } = require('@keystonejs/file-adapters'); into index.js.
  3. 3.
keystone.createList('UploadTest', {
  fields: {
    file: {
      type: File,
      adapter: fileAdapter,
      hooks: {
        beforeChange: ({ existingItem = {} }) => fileAdapter.delete(existingItem),
      },
    },
  },
  hooks: {
    afterDelete: ({ existingItem = {} }) => fileAdapter.delete(existingItem),
  },
});

4 yarn dev

Expected behaviour

yarn dev should run without any error

System information

  • OS: macOS
  • Browser chrome

Additional context

Keystonejs is really cool, hopefully I can benefit more from it, thanks!

Most helpful comment

Looks like you need to add the @keystonejs/file-adapters to your project.

Run npm i @keystonejs/file-adapters or yarn add @keystonejs/file-adapters

>All comments

Looks like you need to add the @keystonejs/file-adapters to your project.

Run npm i @keystonejs/file-adapters or yarn add @keystonejs/file-adapters

Was this page helpful?
0 / 5 - 0 ratings

Related issues

molomby picture molomby  路  11Comments

thekevinbrown picture thekevinbrown  路  31Comments

arnaud-zg picture arnaud-zg  路  18Comments

jesstelford picture jesstelford  路  14Comments

amorote picture amorote  路  21Comments