Created a project with custom npx command
"bin": {"myCommand": "./bin/myJsFile.js"}
js file is in ES6 and use the import statement to import a file say importFile written in ES6.
I deploy the command locally using npm i -g
when I try to run it locally using npx.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\project\src\importFile ' imported from C:\project\src\bin\myJsFile.js
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:416:11)
at moduleResolve (node:internal/modules/esm/resolve:932:10)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
Related
How to apply a patch for Drupal modules files through a composer.json file?
Basically, I have installed slick module and customised code and created a patch file using "git diff" command. Slick module file path is modules/contrib/slick/ directory. Below is the code that i have written in the composser.json file.
"require": {
"drupal/slick": "^2.7",
}
----------------------------------
"patches": {
"drupal/slick": {
"Slick custom changes": "patches/slick/slick.patch"
},
But when running composer install, it just removes this slick package from "modules/contrib/slick, but does not reinstall or add the patch.
If i remove "Slick custom changes": "patches/slick/slick.patch" from composer.json and execute composer install cmd then it install slick module.
How to avoid removing this package and applying the patch?
the errror is 'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
ive tried
npm install
npm install react-scripts --save
npm i -g react-scripts
https://github.com/mareyam/Complete-Maryam-s-Restaurant
i uploaded this code on github without .json file
now im trying to donwnload and use it but cant because ,json file ive lost. ive tried using json file from anothr project but not working
I would recommend using create-react-app to build this project. Run the command, cd into the directory then start the app.
npx create-react-app name_of_app
cd name_of_app
npm start
This will be good enough for development, and you can add all your components into the src/ folder. Here's the documentation for how to start building react web apps.
To get the production build (which I think is what you're trying to go for), run npm run build which will save the build in the build/ folder.
Any time you use a different machine, just pull the project from github and run npm i. I'm assuming that you were talking about the package.json file. This shouldn't be a big deal if you set everything up correctly.
I want create orbitdb bundle
In README on github i see this example
npm install orbit-db ipfs
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
i am using es6 import
In example for browser on github
// Import IPFS module
import IPFS from 'ipfs'
// Import OrbitDB module from 'orbit-db', eg. directory to its package.json
import OrbitDB from '../../..'
But it is not work
I build es5 modules
npm run build:es5
it is build not es5 modules
To build this example run the following commands
npm install
npm run build:examples
after that you can open examples/browser/browser-webpack-example/index.html in your browser.
Edit: We updated the documentation to run the examples
I have created a node.js project, within which I have created a truffle directory and initialised its project. I have installed the openzeppelin (npm install #openzeppelin/contracts) library in this truffle project directory, but nothing appears to have been installed, although I did not received any error during the install process. The import statement in my project displays the error hereafter:
import "#openzeppelin/contracts/token/ERC721/ERC721Full.sol";
Source "#openzeppelin/contracts/token/ERC721/ERC721Full.sol" not found: File import callback not supported
It looks like they changed the name, and now the contract name is
ERC721.sol and not ERC721Full.sol, so try
import "#openzeppelin/contracts/token/ERC721/ERC721.sol";
Try this:
import "github.com/openzeppelin/contracts/token/ERC721/ERC721Full.sol"
I want to import cytoscape.js library in my angular project, but I don't know how to do it. As far as I know, there is no official cytoscape module for angular, is there any way to import cytoscape manually?
Philipp's answer actually works but it looks like an improper inclusion of a library using both npm install AND an actual JS file. You can skip the npm install step from the instruction and it will work the same.
To actually use npm installed package I advise the following:
Run npm install cytoscape
Run npm install --save #types/cytoscape for proper IDE tips.
In your component add import * as cytoscape from 'cytoscape';
Use it like expected e.g. let cy = cytoscape({...})
UPDATE: Please see the answer of D.C. Joo, this should be the accepted answer.
Actually, it's no problem to import JS libraries in Angular, thats how I do it using npm and Angular6:
Run npm install cytoscape
Download Cytoscape from https://github.com/cytoscape/cytoscape.js/blob/master/dist/cytoscape.min.js
Create a directory scripts in your Angular root directory and place the downloaded file there
Include your downloaded script in your angular.json:
"projects": {
"myproject": {
...
"architect": {
"build": {
...
"scripts": [
"src/scripts/cytoscape.min.js"
]
...
(NOTE: Sorry about the formatting, I tried but it does not want to work)
In the Angular component where you want to use Cytoscape, add declare var cytoscape: any; to the imports
Now you can use Cytoscape like you would normally, have fun :)