0

I am trying to experiment with tinymce npm. I am following their guide and I am stuck here

Include this line of code in the <head> of your HTML page: <script src="/path/to/tinymce.min.js"></script>.

Now inside my head in html, I put this code

<script src="node_modules/tinymce/tinymce.min.js"></script>.

however in the console, there is an error Failed to load resource: net::ERR_FILE_NOT_FOUND

I also find another stack overflow question related to my problem and came across this one

I also tried using the solution here and this is what I did but still the same error.

<script src="scripts/tinymce.min.js"></script>

here is a screenshot of my sample project.

tinymce

I am trying to get tinymce.min.js to index.html which is inside views/blog folder

My question is, how can I make this work?

mplungjan
  • 169,008
  • 28
  • 173
  • 236
bradrar
  • 647
  • 1
  • 8
  • 19

1 Answers1

1

A simple fix for you would be to use a CDN instead of NPM.

Replace this: <script src="node_modules/tinymce/tinymce.min.js"></script>

With this: <script src="https://cdnjs.com/libraries/tinymce"></script>

Below I give my guess at the issue, but I can't be sure without inspecting your whole project:

I think you are neither building nor serving your project. In your sample project I don't see any webpack, gulp, grunt, or other build tool config file. I also don't see anything like Browserify or similar. Those tools would be able to read your script pointing to a local npm folder and replace it with the script from the npm folder. Without those tools, your browser will think the src= string is a web url and the resource will not be found.

As I mentioned, a CDN is a simple fix because that is a real website hosting the script you are asking for. A more complicated approach which is used in commercial development is to have a complete build process and then a server.

John Vandivier
  • 2,158
  • 1
  • 17
  • 23
  • Sorry for not including build tools of sorts. I plan to make this project as quick as possible because it is only a sample file to test tinymce. Thank you for your answer. It works now. – bradrar Mar 02 '19 at 18:33