Adobe-CEP / CEP-Resources

Tools and documentation for building Creative Cloud app extensions with CEP
https://www.adobe.io/apis/creativecloud/cep.html
1.62k stars 824 forks source link

On the Use of Node.js #219

Closed DS0818 closed 5 years ago

DS0818 commented 5 years ago

I don't know why I can't use nodejs when I use it.

index.js:

    // var fs = require('fs');
    const fs= require('fs');
    fs.readFile('f:/2.txt', (err, data) => {
        if (err) throw err;
        alert(data);
      });

manifest.xml: Version="6.0"

                    <CEFCommandLine>
                        <Parameter>--enable-speech-input</Parameter>
                        <Parameter>--enable-media-stream</Parameter>
                        <Parameter>--enable-nodejs</Parameter>
                                                <Parameter>--mixed-context</Parameter>
                    </CEFCommandLine>

ERROR:

[1214/173956.762:INFO:CONSOLE(1)] "Uncaught (in promise) TypeError: t.readFile is not a function", source: file:///C:/Program%20Files%20(x86)/Common%20Files/Adobe/CEP/extensions/adobeIllsrtatorPlug/js/chunk-67f648f4.0879382a.js (1)

This is part of the code.


If I use it incorrectly, can you give me a reference example with code? I want to learn, mainly to use nodejs. Thank you!

embiem commented 5 years ago

Hey, this resource will give you all the info you need to develop with NodeJS in a panel: https://medium.com/adobetech/how-to-build-a-node-js-server-in-a-panel-ba1d63ea67e2

A quick fix might be cep_node.require('fs');, but you should take a look at the mentioned article, as it gives a great introduction.

DS0818 commented 5 years ago

Thank you very much.