I use npm in my client side development.
I use ES6 and I import modules to mapApp.js file from library that I installed in node_modules folder with help of npm tool.
Here is how I import module to mapApp.js file:
import GML from 'ol/format/GML';
Where is 'ol/format/GML' is relative path to node_modules folder.
At some point I create my own module(in config.js file) outside of node_modules folder and I need to import it to mapApp.js file.
Here is picture of project archeticture:
My question is how can I config npm to make search for imports not only in node_modules folder but,
also in specific folder outside of node_modules?
Related
i want to use one vue sfc in another project. I have project1 with componet and make npm package, publish it to own gitlab package registry and use it via npm install. Everything work great, but...
The sfc Foo.vue in FooProject import another one, like: import ChildFooComponent from '#/components/ChildFooComponent.vue'. if i run (npm run dev or build) FooProject, evrything works. But if i make npm package via npm publish and want to use it at BarProject as import Foo from '#FooProject/src/Foo' (FooProject with Foo already is in node_modules)
the build say: cant find module '#/components/ChildFooComponent.vue' in Foo. when i change the import in FooProject in Foo.vue to import FooChildComponent from './components/ChildFooComponent.vue' then every thing works as i expected. i know that # poitns to src folder of actual project, in this case src folder of BarProject, right? but how to tell npm that if # is in FooProject use the src folder of FooProject not BarProject?
I have a package placed in a private GitLab repository. But whenever I try to install this package, after installation, it does not include files that it contains. Only a single file index.tsx gets included.
my original package files:
And its source folder contains all the source code files
After I install the package I only get index.tsx file.
how to solve this problem
I am trying to build an NPM module that will allow an SCSS file to be exported and used across a number of applications.
The SCSS file imports another SCSS in another seperate node module.
My package structure is:
package-name
|--src
| |- overwrite.scss
|
|--package.json
|
|--webpack.config.js
|
|--node_modules
The issue I am facing is that currently I have the paths hardcoded for the import value. For example
$background-color: red;
#import '../node_module/fake_name/dist/core.scss'
I have a dependency in package.json file to ensure that fake_name module will always be in the node_modules folder of any project that will use my npm package.
What I am trying to achieve is set it that the path of #import will always look in the node_modules folder in the root of whatever project it is installed in. I have tired using ~ but I keep getting 'Error: File to import not found or unreadable'
Any help is appreciated.
I have a very simple web project and I'm using npm init to create the package.json file for the project. My project structure is below:
ProjectFolder
--app /this is the folder for js files
--css
--scss
--lib /this is for files like jQuery
--index.html
When adding a node package, it will create a node_modules folder like this:
ProjectFolder
--node_modules
--app /this is the folder for js files
--css
--scss
--lib /this is for files like jQuery
--index.html
Let's say I add jquery through npm install and make it a dependency. Is it good practice to link to the jquery file in node_modules from my index.html or move the jquery file to my lib folder?
Is there a way to move the jquery file to my lib folder when installing?
I don't want to move the node_modules folder to the server and want to know the best practice.
Your package.json is essentially your link. It contains a list of the packages you are dependent on and their versions. If you install something using npm install it has to be a published npm package on an npm repository somewhere (either public or private). It downloads a zipped version of the npm package and unzips it into node_modules. Anything in there is automatically then available to your app. Hope that helps.
I am trying to create an npm module. In my src directory I have index.ios.js and index.android.js. In my entry key of package.json I have index.js. This is resulting in import errors. Is it possible to use platform specific extensions in npm module?
Here is my package - https://github.com/Noitidart/react-native-buttonex
In summary - What should entry be if src/index.android.js src/index.ios.js