I am building my angular app from the angular cli starter.
The problem is being suggested in the error below.
C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\#angular\cli\models\config\config.js:76
throw new InvalidConfigError(common_tags_1.stripIndent
^ InvalidConfigError: Parsing 'C:\Users\Afropepe\Desktop\development\buy-ticket.angular-cli.json'
failed. Ensure the file is valid JSON. Error: Unexpected token ] in
JSON at position 535
at InvalidConfigError (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\#angular\cli\models\config\config.js:11:9)
at Function.fromConfigPath (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\#angular\cli\models\config\config.js:76:19)
at Function.fromProject (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\#angular\cli\models\config.js:88:46)
at Object. (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\#angular\cli\commands\build.js:7:35)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
Please ensure your file named ".angular-cli.json" contains JSON format, in my case I added some comments on the JSON file, and even when VS compile, this is not valid
"assets": [ "assets"],
//"index": "myindexfile.html",
"main": "main.ts",
Please make sure your file is has a right JSON format
The error that I was getting is below:
\#angular\cli\models\config\config.js:89
throw new InvalidConfigError(common_tags_1.stripIndent `
^
I had some error, when tried to import in angular-cli.json in scripts file
"../node_modules/tether/dist/js/tether.min.js"
after
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
So maybe this problem occurs when the one library needs to include another library before it.
angular-cli.json Content:
//"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
Inside the .angular-cli.json/ angular-cli.json just remove ////"index": "index.html", because it won't considering as comment and throw some exception.
Correct Output:
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
I had same error, resolved by replacing with new angular-cli.json and reconfigure.
Related
IDE: Replit
Good afternoon, thanks for checking out.
I wanted to implement absolute imports to my node project, but something odd is happening whenever I try to run the code.
Here are the things I set for my jsconfig.json file:
{
"compilerOptions": {
"baseUrl": "src"
}
}
Now, this is how i'm calling the file I need inside another one:
const {title} = require('util.js')
Oddly, replit's intellisense shows up the right path:
Thumbs Up From Replit
But then, when I finally execute the code, I get this error message:
Error: Cannot find module '/home/runner/Moniqueta-Discordjs/node_modules/util.js/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:353:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/home/runner/Moniqueta-Discordjs/src/commands/rps.js:2:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
code: 'MODULE_NOT_FOUND',
path: '/home/runner/Moniqueta-Discordjs/node_modules/util.js/package.json',
requestPath: 'util.js'
}
I tried following the error by adding a "valid main entry to my package.json" file, like this:
{
"name": "moniqueta-discordjs",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"keywords": [],
"author": "sum117",
"license": "ISC",
"dependencies": {
"#replit/database": "^2.0.2",
"discord.js": "^13.8.0",
"src": "^1.1.2",
"util.js": "^0.0.0"
}
}
And when I checked it, it had "util.js" as a declared dependency, I really don't understand what's going on.
Thanks for reading. What am I missing? I really would love this to work...
If my explanation is not enough, you can access my open source code via the link.
I was following an introduction tutorial using anchor (solana framework), it is based in the official github.
In the testing part, I used anchor test command and I got this error:
BPF SDK: /home/sebastian/.local/share/solana/install/releases/1.9.12/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
Finished release [optimized] target(s) in 3.86s
cargo-build-bpf child: /home/sebastian/.local/share/solana/install/releases/1.9.12/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so
To deploy this program:
$ solana program deploy /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so
The program address will default to this keypair (override with --program-id):
/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1-keypair.json
yarn run v1.22.17
$ /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/.bin/mocha -t 1000000 tests/
Error: Cannot find module '/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/#project-serum/anchor/dist/cjs/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:353:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/tests/basic-1.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
at async formattedImport (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
at async Object.exports.requireOrImport (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/mocha/lib/nodejs/esm-utils.js:48:32)
at async Object.exports.loadFilesAsync (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/mocha/lib/nodejs/esm-utils.js:88:20)
at async singleRun (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at async Object.exports.handler (/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/mocha/lib/cli/run.js:374:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This is my package.json:
{
"name": "basic-1",
"version": "0.24.2",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://github.com/project-serum/anchor#readme",
"bugs": {
"url": "https://github.com/project-serum/anchor/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/project-serum/anchor.git"
},
"engines": {
"node": ">=11"
},
"scripts": {
"test": "anchor test --skip-lint"
},
"dependencies": {
"#project-serum/anchor": "^0.24.2"
}
}
I really appreciate any information about it. I also attach the tutorial and anchor's github link.
https://github.com/project-serum/anchor
https://youtu.be/CmG5_sIas1Q
Try re-installing #project-serum/anchor
yarn add #project-serum/anchor
In your anchor.toml file, try changing the value of 'test' to mocha tests/test.js , replace test.js with whatever the name of your file in tests.
Go check node_modules/#project-serum/anchor if you don't have a "dist" folder there you will have to run yarn add#project-serum/anchor again. When you can see that the "dist" folder was properly installed you'll be able to run your tests again.
I have protractor running with typescript and I'm trying to follow the steps on the link
Using require with relative paths
so i can test drag and drop with native javascript from this repo https://gist.github.com/druska/624501b7209a74040175 because there is an issue with Chromedriver and it's not working.
Package.json
"dependencies": {
"#types/jasmine": "^3.5.10",
"#types/node": "^13.11.0",
"dragndrop": "./src/utils/functions/dragndrop/",
"protractor": "^5.4.4",
"typescript": "^3.8.3"
},
Package.json of the module
{
"name": "dragndrop",
"version": "0.1.1",
"description": "Drag and drop object",
"main": "./index.js",
"dependencies": {}
}
This is what I have in my code
var DragAndDrop = require('dragndrop');
var dragAndDropFn = new DragAndDrop();
...
browser.executeScript(dragAndDropFn, elem2, elem1);
When I run the test I get
E/launcher - Error: Error: Cannot find module 'dragndrop'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Work\GIT\OSM\Web\temp\src\test-suites\feature\routes-planning\routes-planning-list.spec.js:17:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Can someone tell what do I need to do/change in order to use the javascript module?
Thanks in advance
I'm new to electron and have made my first electron application, it runs normally running npm start but when using npm run I am unable to execute my application. (I am running ubuntu linux) The cli gives this error message when running the executable file:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/app/index.js'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Object.<anonymous> (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/browser/init.js:171:8)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
This is my package.json :
{
"name": "cocoa",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron main.js",
"package-linux" : "electron-packager . --platform=linux --arch=x64 --electron-version=1.4.13"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^8.7.1"
}
}
this is the main.js file :
const electron = require('electron')
const {app, BrowserWindow} = electron
app.on('ready', ()=> {
let win = new BrowserWindow({
width:400,
height:400
})
win.loadURL('http://google.com')
})
Does anyone know what I am doing wrong, thank you for your help.
Ok, that was really stupid. I had named the main js file for the project main.js when in actual fact it had to be named index.js
problem solved!
I am doing the node.js lesson from lynda.com and am unable to find what is causing the "Error: Can not find module". From everything I can tell the package.json has the flight module in it.
Everything has been working so far so I know node.js is installed and running correctly. The way I am running this file is by typing "node app.js" at the command line. Also all of the files are in the same folder.
Here is the console log:
C:\Users\Jonathan\Desktop\flight>node app.js
module.js:340
throw err;
^
Error: Cannot find module './flight'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\Jonathan\Desktop\flight\app.js:1:76)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
C:\Users\Jonathan\Desktop\flight>
Here is the code.
Package.json file
{
"name": "flight",
"version": "1.0.0",
"description": "a module for keeping track of a flight",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "JBaxter",
"license": "ISC"
}
index.js file
var number, origin, destination;
exports.setNumber = function (num){
number = num;
};
exports.setOrigin = function (o){
origin = o;
};
exports.setDestination = function (d){
destination = d;
};
exports.getInfo = function() {
return {
number: number,
origin: origin,
destination: destination
};
};
app.js file
var flight = require('./flight');
flight.setOrgin('LAX');
flight.setDestination('DCA');
flight.setNumber(462);
console.log(flight.getInfo());
Any help with be great. I thought the name within the package.json file was your module but maybe I am incorrect. Thanks in advance.
"./flight" does not evaluate to index.js in your case.
If you create a subdir :
flight
- index.js
then you can require("./flight") and have it evaluated to "./flight/index.js".
In your case, simplest thing you could to do :
require("./index.js");
you can do it in the following way:
var flight = require('./index.js');
OR
var flight = require('./index');
Following code will not work because the node will look for module named 'flight' in node_modules folder
var flight = require('flight');