dadi / cdn

CDN is a Just-in-time asset manipulation and delivery application, providing a complete content distribution/delivery solution
https://dadi.cloud/en/cdn
Other
217 stars 43 forks source link

error: Error: Cannot find module '/Users/eduardoboucas/Sites/cli/wrapper/updater.js' #521

Closed maicoly closed 3 years ago

maicoly commented 3 years ago

Hello everyone, I cannot install CDN DADI I get this error, I have tried this guide but I get this error:

maicoly@maicoly-Alienware-Area-51m:~/boxbeep/cdn_boxbeep$ dadi cdn new
module.js:540
    throw err;
    ^

Error: Cannot find module '/Users/eduardoboucas/Sites/cli/wrapper/updater.js'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

link page:

https://github.com/dadi/cdn https://docs.dadi.cloud/cdn/3.4

can you help me?

jimlambie commented 3 years ago

Hi @maicoly

Looks like a problem installing from the CLI. I'd try installing directly from NPM instead:

cd ~/boxbeep/cdn_boxbeep
npm init -y
npm i @dadi/cdn

This will give you the latest CDN version, which should be 4.0.0

jimlambie commented 3 years ago

You'll also need a file to act as the entry point. Add a file called "index.js" with the following content:

require('@dadi/cdn')

Now, running npm start should run the CDN application.

maicoly commented 3 years ago

Hi @jimlambie , thanks for your support I have this problem when running npm start

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'start' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]

also when using thenode index.js command

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open './config/config.development.json'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at loadFile (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:452:19)
    at /home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:611:24
    at Array.forEach (<anonymous>)
    at Config.loadFile (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:609:13)
    at new Config (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/@dadi/cdn/config.js:709:8)
    at Object.<anonymous> (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/@dadi/cdn/config.js:889:18)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)

the version of node I use is 8.9.4 any ideas?

jimlambie commented 3 years ago

@maicoly I think the defaults for npm start were introduced in a later version. You can add this block into package.json and it will work:

"scripts": {
  "start": "node index.js"
}

As for the next error, yes we will need to add a configuration file:

  1. create new folder config
  2. add file config.development.json

Sample contents for the configuration file are below (and info regarding the settings available at https://docs.dadi.cloud/cdn/3.4#configuration)

{
  "cluster": false,
  "server": {
    "host": "127.0.0.1",
    "port": 8001
  },
  "images": {
    "directory": {
      "enabled": true,
      "path": "./images"
    },
    "s3": {
      "enabled": false,
      "accessKey": "",
      "secretKey": "",
      "bucketName": "",
      "region": ""
    },
    "remote": {
      "enabled": false,
      "path": ""
    }
  },
  "assets": {
    "directory": {
      "enabled": true,
      "path": "./public"
    },
    "s3": {
      "enabled": false,
      "accessKey": "",
      "secretKey": "",
      "bucketName": "",
      "region": ""
    },
    "remote": {
      "enabled": false,
      "path": ""
    }
  },
  "caching": {
    "ttl": 60,
    "directory": {
      "enabled": true,
      "path": "./cache/",
      "autoFlush": true,
      "autoFlushInterval": 120
    },
    "redis": {
      "enabled": false,
      "host": "127.0.0.1",
      "port": 6379
    }
  },
  "logging": {
    "enabled": true,
    "level": "debug",
    "path": "./log",
    "filename": "cdn",
    "extension": "log",
    "accessLog": {
      "enabled": true
    }
  },
  "security": {
    "maxWidth": 10000,
    "maxHeight": 20000
  },
  "auth": {
    "clientId": "1235488",
    "secret": "asd544see68e52"
  },
  "headers": {
    "useGzipCompression": true,
    "cacheControl": {
      "default": "public, max-age=3600",
      "paths": [

      ],
      "mimetypes": [
        { "image/jpeg": "public, max-age=86400" },
        { "text/css": "public, max-age=86400" },
        { "text/javascript": "public, max-age=86400" },
        { "application/javascript": "public, max-age=86400" }
      ]
    }
  },
  "feedback": false
}
maicoly commented 3 years ago

Hi @jimlambie, thanks again for your support the command node index.js is OK! maicoly@maicoly-Alienware-Area-51m:~/boxbeep/cdn_boxbeep$ node index.js

⠋ Starting @dadi/cdn...[2020-11-16 11:30:39.552] [LOG]    Process 22756 is listening for incoming requests
[2020-11-16 11:30:39.553] [ERROR]  (node:22756) ExperimentalWarning: The http2 module is an experimental API.
✔ Started DADI CDN
@ http://127.0.0.1:8001

  ┌──────────────────────────────────────────┐
  │ DADI CDN                                 │
  ┌──────────────┬───────────────────────────┐
  │ Protocol     │ http                      │
  │ Version      │ 4.0.0                     │
  │ Node.js      │ 8.9                       │
  │ Environment  │ development               │
  └──────────────┴───────────────────────────┘

  ℹ Documentation at https://docs.dadi.cloud
  ℹ <CTRL> + C to shut down

   ▓▓▓▓▓  ▓▓▓▓▓▓▓
               ▓▓▓▓
      ▓▓▓▓▓▓▓    ▓▓▓▓
               ▓▓▓▓
          ▓▓▓▓▓▓▓

  © 2020 DADI+ Limited (https://dadi.cloud)
  All rights reserved.

however when I open the url localhost: 8001 I get:

{"statusCode":404,"message":"File not found: /home/maicoly/boxbeep/cdn_boxbeep/public/no-default-configured"}

do i need any other file?

now with npm start (adding the configuration you sent me!)

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'start' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]
jimlambie commented 3 years ago

Odd.... can you try npm run start intead?

jimlambie commented 3 years ago

As for the missing file message - you'll need images in a folder called "images", or whatever is configured (I think the default is just an "images" directory.

Then you can choose one of the files from that folder and try http://localhost:8001/my-file.jpg. The message you got indicates that you requested no file.

A response from http://localhost:8001/hello should also indicate it's running fine...

maicoly commented 3 years ago

the output again is:

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'run',
1 verbose cli   'start' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "run" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]

package.json:

{
  "scripts": {
    "start": "node index.js"
  },
  "name": "cdn_boxbeep",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@dadi/cdn": "^4.0.0"
  }
}
jimlambie commented 3 years ago

Ah - you have two "scripts" blocks. Move "start" inside the one further down

maicoly commented 3 years ago

Thxs, @jimlambie; ran without any problem! I put an image called picture1 PNG format at the time of making the request http://127.0.0.1:8001/picture1 stays loading and does not respond to the request, so I note is that the image extension is needed in the request so that it reads from ../images/picture1.xxx but if not I put it it reads from ../public/picture1 any ideas?

Thxs again for support!

jimlambie commented 3 years ago

@maicoly pleased it's working for you!

Correct, CDN determines what to do based on the file extension. The configuration blocks for "images" and "assets" control where CDN will look for files that are requested - if the extension isn't a typical image format then it'll assume it's an asset (think CSS, JS, fonts, etc) and use the "assets" block to try to locate it:

e.g.

"assets": {
    "directory": {
      "enabled": true,
      "path": "./public"
    },
maicoly commented 3 years ago

@jimlambie, Maybe I did not understand well, what happens is that in the request it delays responding image my directory and files: image

maicoly commented 3 years ago

maybe, the problem is?: image

jimlambie commented 3 years ago

maybe, the problem is?: image

You can actually ignore this for the time being, it's unrelated

jimlambie commented 3 years ago

I think perhaps in the case of returning from "assets" it doesn't know what to do with an extension-less file? It's hard to know without debugging properly. Can you add file extensions to make it more obvious?

maicoly commented 3 years ago

Sure, I put the extensions with this result: image image

jimlambie commented 3 years ago

Hmmm... seems strange. Could you change the configuration of the images block (images.directory.path) to the absolute path?

"images": {
    "directory": {
      "enabled": true,
      "path": "/home/maicoly/boxbeep/cdn_boxbeep/images"
    },
maicoly commented 3 years ago

@jimlambie thxs, it's solved!!! wow! thxs. YES, is strange! Thxs again for support, I will be investigating many more!