endenwer / npm-rails Goto Github PK
View Code? Open in Web Editor NEWNPM support for Rails with Bundler-like DSL
License: MIT License
NPM support for Rails with Bundler-like DSL
License: MIT License
In a few of my apps I have 2 different javascript files - application and admin. There can be some overlap so I often have a common folder as well. Since they're pretty independent, it would be nice to be able to have 2 or 3 npm_dependency files, or at least output files for including.
Let me know if you're interested. I'm going to do some work and see what I can build this weekend towards these 2 issues. Thanks!
I would love for this to work...
I get this error on rake npm:install
** Invoke npm:install (first_time)
** Execute npm:install
npm install --prefix /Users/Lorin/Work/bmsc --loglevel error alpaca@"latest"
/Users/Lorin/Work/bmsc
└── [email protected]
/usr/local/bin/browserify /Users/Lorin/Work/bmsc/tmp/npm-rails/bundle.js > /Users/Lorin/Work/bmsc/vendor/assets/javascripts/npm-rails/development/npm-dependencies.js
Error: Cannot find module 'alpaca' from '/Users/Lorin/Work/bmsc/tmp/npm-rails'
at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
at process (/usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
at ondir (/usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
at load (/usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:123:15)
rake aborted!
Command failed with status (1): [/usr/local/bin/browserify /Users/Lorin/Wo...]
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/file_utils.rb:66:in block in create_shell_runner' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/file_utils.rb:56:in
sh'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/npm-rails-0.2.1/lib/tasks/npm.rake:23:in block (3 levels) in <top (required)>' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/npm-rails-0.2.1/lib/npm/rails/package_bundler.rb:18:in
bundle'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/npm-rails-0.2.1/lib/npm/rails/package_bundler.rb:7:in bundle' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/npm-rails-0.2.1/lib/tasks/npm.rake:14:in
block (2 levels) in <top (required)>'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in block in execute' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in
each'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in execute' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in
block in invoke_with_call_chain'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in
invoke_with_call_chain'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in invoke' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in
invoke_task'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in block (2 levels) in top_level' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in
each'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in block in top_level' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in
run_with_threads'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in top_level' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in
block in run'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in standard_exception_handling' /Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in
run'
/Users/Lorin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in <top (required)>' /Users/Lorin/.rbenv/versions/2.3.0/bin/rake:22:in
load'
/Users/Lorin/.rbenv/versions/2.3.0/bin/rake:22:in <main>' /Users/Lorin/.rbenv/versions/2.3.0/bin/ruby_executable_hooks:15:in
eval'
/Users/Lorin/.rbenv/versions/2.3.0/bin/ruby_executable_hooks:15:in `
This is my npm_packages file:
npm 'alpaca'
I have installed browerify globally
This is the full error:
/home/amadeus/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /home/amadeus/.rbenv/versions in PATH, mode 040777
npm install --prefix /mnt/c/Users/Amadeus Pagel/Documents/readpaths --loglevel error cytoscape@"latest" cytoscape-popper@"latest"
Error: EACCES: permission denied, mkdir '/mnt/c/Users/Amadeus'
TypeError: Cannot read property 'get' of undefined
at errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:83:20
at cb (/usr/lib/node_modules/npm/lib/npm.js:224:22)
at /usr/lib/node_modules/npm/lib/npm.js:262:24
at /usr/lib/node_modules/npm/lib/config/core.js:81:7
at Array.forEach (<anonymous>)
at /usr/lib/node_modules/npm/lib/config/core.js:80:13
at f (/usr/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/lib/node_modules/npm/lib/config/core.js:178:20)
at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:234:20)
at /usr/lib/node_modules/npm/lib/config/set-user.js:23:20
at /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53
at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:284:29
at FSReqWrap.oncomplete (fs.js:152:21)
/usr/lib/node_modules/npm/lib/utils/error-handler.js:205
if (npm.config.get('json')) {
^
TypeError: Cannot read property 'get' of undefined
at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at emitOne (events.js:116:13)
at process.emit (events.js:211:7)
at process._fatalException (bootstrap_node.js:378:26)
rails aborted!
Command failed with status (7): [npm install --prefix /mnt/c/Users/Amadeus ...]
/mnt/c/Users/Amadeus Pagel/Documents/readpaths/bin/rails:9:in `require'
/mnt/c/Users/Amadeus Pagel/Documents/readpaths/bin/rails:9:in `<top (required)>'
/mnt/c/Users/Amadeus Pagel/Documents/readpaths/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => npm:install
Hey, me again!
I was wondering if there's a way to specify which files I want to be compiled into npm-dependecies.js
from a specific package. An example is to use moment.js and specify which locale file I want to be included. The files are already inside node_modules/moment/locales
, but I can't see a way to put them into npm-dependencies.js
.
Thanks!
Hi! Is there a way to ignore dependencies from a specific package?
I will explain why I'm asking this:
I'm using react-rails gem to deal with react library, but I would like to use npm-rails to deal with other react components, like react-big-calendar.
To get rake npm:install
to work in this case, I had to insert react and react-dom in the npm_packages
file, making a duplicate of react and react-dom, even with require: false
, the code still is compiled to npm-dependencies.js
.
What should I do in this case?
Thanks!
I want to use this gem for rails 3 application. But due to some reason i am still unable to import the packages from node_modules.
Please guide me if i am missing something.
For example:- I was trying to add the npm package https://www.npmjs.com/package/react-sortable-tree
but when i require this by the statement
require 'react-sortable-tree''
or
require 'react-sortable-tree/react-sortable-tree''
it raise error 404
Thanks in advance..
I still cannot figure out why this is happening, but I just installed the latest version of npm-rails and I have an npm_packages that look like this:
# Browserify is required.
# You can install it globally and delete from here.
npm 'browserify', require: false, development: true
# Add some npm packages
npm "jquery.scrollTo"
After running rake npm:install, on the browser, I got this error:
npm-dependencies.self-0c41d68….js?body=1:10290 Uncaught TypeError: Cannot set property 'scrollTo' of undefined
That line looks like this:
window.Jquery.scrollTo = require('jquery.scrollTo')
so, something is referring to jQuery as Jquery. I have yet to find it, but tmp/npm-rails/bundle.js contains that like:
window.Jquery.scrollTo = require('jquery.scrollTo')
This gem has been really helpful bridging the gap between Rails and NPM. One thing that's missing for me is a lock file similar to how a Gemfile and Gemfile.lock work. I know you can lock the versions, but I think it's still missing an important component for me. Here's how I imagine it working:
rails npm:install
rails npm:update
extra
I can take some time to work on it if it sounds like something you agree with and would be interested in having. Thanks for your work on this so far.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.