I wanted to execute file writing with javascript in the rails view, and after examining various things, I found that it was possible to use node.js, so I tried it.
Error messageWhen I tried to use the following preparations, I got a browserify related error.
(1) node.js is already installed (installed when building the rails environment)
(2) Install browserify
(3) Install browserify-rails
When the page is displayed in the browser, the following error occurs.
Unable to run node_modules/.bin/browserify.Ensure you have installed it with npm.
-I moved the js file for writing files from the command prompt.
$node sample.js
const fs = require ('fs')
fs.writeFileSync ("output.txt", "hello, world")
-The file join operation using browserify from the command prompt has been successfully completed.
$browserify main.js -o build.js
(OS) Windows 10
(WSL) Ubuntu 18.04.2 LTS
(Rails) 6.0.1
(ruby) 2.5.1p57
(browserify) 4.3.0
(node.js) v11.14.0
(npm) 3.5.3
There was an error message "Unable to run node_modules/.bin/browserify."
When I checked the above path, there was no browserify in ./bin.
(Path: app/node_modules/.bin /)
Thank you for helping me if you understand the possible cause (´;ω;`)
-
Answer # 1
Related articles
- javascript - i want to eliminate error 404
- [javascript] an error is displayed on the console when writing with an immediate function
- javascript - i got the error these relative modules were not found while using vue router
- javascript - [gas] how to write a program that gets the latest message and branches
- javascript - i want to use the js code published on another site, but i get an error
- javascript - how to write when using multiple arrow functions
- javascript - i'm making tetris with js, but i don't know how to resolve the error
- javascript - [gas] write to a spreadsheet using a shortcut
- javascript - resolve react error "'map' of undefined"
- javascript - how to write the process to put the id of the clicked element in a variable
- javascript - i want to issue an error message if the checkbox is not checked
- javascript - if the error continues in express, cannot set headers after they are sent to the client
- javascript - about roulette creation error
- javascript - i want to write a script to send a file with the touch of a button
- javascript - js error is displayed
- javascript - about the error "cannot read property'indexof' of null"
- javascript - in express, i get an error saying cannot set headers after they are sent to the client
- javascript - i get a module not found error when building a react environment
- javascript - react how to write an input check
- javascript - [ubuntu] error when installing visual studio code
- javascript : Problem with sending data to Node.js server!
- javascript : How to connect node js to browser?
- javascript : How to implement filter logic?
- javascript : How do I use document in Node JS?
- javascript : npm rebuild --verbose sharp gives an error
- javascript : Is it possible to somehow get Request Headers via node-fetch?
- javascript : How can I pass the value of a variable to a text file?
- javascript : Multer does not save files
- javascript : Increase the volume of processed files on the node js server
- javascript : why is there no real time data transfer over socket.io (node.js, express)
Although browserify is probably installed in the global area,
When Rails browses browserify, it looks for the node_module under the project directory, so browserify is not found under node_modules and it seems that an error has occurred.
In the project directory,
Runto try a local installation of browserify.