Related SO question: npm - package.json override main field (I tried to do something like this using the webpack.mix.js but it didn't work).
I have a Laravel 5.5 application with npm v5.6.0 and node v9.4.0 (I'm thinking that this maybe is an npm/node version issue, but I don't have an environment to test with older versions ATM). Everything is working fine and I'm working this app for a while now and I've installed some node modules and used bootstrap.js and app.js to require/import npm modules, but it seems there is a problem with the bootstrap-treeview; I've spent more than 2 hours to try and make webpack compile with this module with no luck; I always get that error after npm run dev:
ERROR Failed to compile with 1 errors
This dependency was not found:
bootstrap-treeview in ./resources/assets/js/bootstrap.js
I tried to use both require and import inside bootstrap.js and I have even tried an other available module webpack-bootstrap-treeview which it seems that it doesn't have bower dependency:
//import "~/node_modules/bootstrap-treeview";
//require("bootstrap-treeview");
//import "bootstrap-treeview";
//import "~/node_modules/webpack-bootstrap-treeview";
//require("webpack-bootstrap-treeview");
import "webpack-bootstrap-treeview";
bootstrap-treeview: https://www.npmjs.com/package/bootstrap-treeview
webpack-bootstrap-treeview: https://www.npmjs.com/package/webpack-bootstrap-treeview
I know I can just use laravel-mix to compile the js files directly to the app.js and I will probably do, but I want to have my modules organized and I'd like to find the culprit on this issue.
EDIT
I've also tried to delete the node_modules directory then npm install and even npm cache clear, nothing worked for the webpack to compile without that error.
Looks like there are some misnamed files. Renaming the bootstrap-treeview files in node_modules\bootstrap-treeview-2\dist to bootstrap-treeview-2 allows webpack to successfully complete. Oh, and I installed the bootstrap-treeview-2 package because bootstrap-treeview has been archived.
Related
Hi this is my first npm package (it is a React component library) that Ive published and I realized that while it works perfectly fine when used with Webpack v4.x, the issue is that anyone who uses Webpack v5.x or uses npx create-react-app command to create a React app and tries to use my npm package will encounter a bunch of errors due to Webpack v5.x no longer including polyfills.
Thus the person will have to install a number of npm packages and then configure their Webpack.config.js file to include a number of fallbacks.
For example, the person will get 15-20 error messages when they try to use my npm package such as cannot resolve crypto or cannot resolve http, etc. This is due to one of the dependencies for my npm package being the npm package ‘ws’.
Is there anything I can do on my end when publishing my npm package so that these additional steps for users of my npm package is not necessary and they won’t have to install a bunch of npm packages and then edit their Webpack.config.js file just to able to use my npm package?
I tried to deploy to Meteor Galaxy and it didn´t work at all, although everything seems to be working on localhost.
At first, my app was uploaded, but than failed to start. At least, the containers start right now, but than my App is crashing. I think it is a systematic fail within my app structure. Perhaps some npm dependencies are missing in package.json or I need to debug some npm installations?
I don´t think that I have understood exactly how npm is working within Meteor, which dependencies I need to have or what I have to import/require to use npm packages correctly. The meteor docs did not help.
Here are my error logs:
Note: you are using a pure-JavaScript implementation of bcrypt.
While this implementation will work correctly, it is known to be
approximately three times slower than the native implementation.
In order to use the native implementation instead, run
meteor npm install --save bcrypt
in the root directory of your application.
/app/bundle/programs/server/node_modules/fibers/future.js:280
throw(ex);
^
Error: Can't find npm module 'meteor/browser-policy-common'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
at Object.require (/app/bundle/programs/server/boot.js:230:17)
at makeInstallerOptions.fallback (packages/modules-runtime.js:641:18)
at require (packages/modules-runtime.js:234:16)
at meteorInstall.imports.startup.server.browser-policy.js (imports/startup/server/browser-policy.js:1:32)
at fileEvaluate (packages/modules-runtime.js:333:9)
at require (packages/modules-runtime.js:228:16)
at meteorInstall.imports.startup.server.index.js (imports/startup/server/index.js:1:66)
at fileEvaluate (packages/modules-runtime.js:333:9)
at require (packages/modules-runtime.js:228:16)
at meteorInstall.server.main.js (server/main.js:1:14)
at fileEvaluate (packages/modules-runtime.js:333:9)
at require (packages/modules-runtime.js:228:16)
at /app/bundle/programs/server/app/app.js:3668:1
at /app/bundle/programs/server/boot.js:338:34
at Array.forEach (native)
at Function._.each._.forEach (/app/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
It does not matter which module is missing, it seems to be that Galaxy can´t find any of the used npm modules. Before that try, I had the same error with another npm module. Than I just deleted the Npm.require of that module in my code. Now, I have the same error, just with another module.
I think I missed something during the local usage of npm. I am a complete beginner. Everything worked fine locally and now I can´t bring it online. I am using Windows.
It was a general issue, because I never used the --save flag when adding npm packages and therefore had no dependencies of them in my package.json. I removed node_modules and runned meteor npm install --save for every npm package and the error had been gone (additionally I removed the browser-policy package for other reasons).
What is the best way to include bootstrap.css in my sails.js project? I have installed the bootstrap npm package.
npm install bootstrap#3
I believe I am suppose to import that in assets/styles/importer.less but have yet to get it working.
It looks like you may have to use Grunt to compile the less, try running
npm install - just to make sure all the dependencies are pulled in
and then run
grunt - to build the assets
http://sailsjs.org/documentation/concepts/assets/default-tasks#?less
https://github.com/gruntjs/grunt-contrib-less
https://github.com/WebDevStudios/CLI-Cheat-Sheet/blob/master/grunt-commands.md
When I run
npm install lodash
it comes back with no errors and I can see the lodash folder in my node_modules folder. However, when I then try to run the code using
npm run
it gives me an error that it 'Cannot find module 'lodash''.
The file is included using the code
var _ = require('lodash');
I'm using node.js version 6.2.1, upgraded from version 4.4.5 where I had the same problem. This seems to be a problem just for me, someone else has installed the code without getting this problem. I can also perform other installs without any problems. I've tried deleting the node_modules folder and cleaning the npm cache but neither made any difference.
Any ideas?
I've just installed the babel-cli module locally to my project but when I run babel test.js in the terminal it outputs that the *command babel is uknown*.
What I figured out is that npm is trying to find the module in my globally installed modules instead of my project modules, how can I fix it?
Sorry for the silly question but I'm not finding a solution.
You can either
Use the babel installed in you project - node_modules/.bin/babel test.js
Add a script in your package.json and run it via npm - npm run <script_name>. npm will use the version of babel installed in your project
When you run babel. It looks for global npm directory and can't find it there.
2 ways but one is redundant.
You can link your local path to global npm directory which is
redundant and wont work for the next project. Don't never do this.
Or install it globally. That how npm works for now.
There is a discussion on that. And here is a good article. http://www.joezimjs.com/javascript/no-more-global-npm-packages/