I am trying to run an ember.js app on my laptop but after installing the ember-cli and trying to run ember --version command I get an error.
To install ember-cli I used the following command - npm install -g ember-cli
It is probably important to mention that when I run ember --version command outside of the app directory it works, but when I run it inside app directory it crashes and gives error.
Node.js version - 8.11.3
This is the error that I get:
ember --version
/Users/user/go/src/github.com/apps/app/node_modules/ember-cli/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/user/go/src/github.com/apps/app/node_modules/ember-cli/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
As suggested in comments by Buck Doyle I changed Node.js version to 14.5.0 and ran ember --version command again, but I got a different error this time:
Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (83)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.13.1
Stack Trace and Error Report: /var/folders/bt/p_dtgwnd23gbv8nc7v_wpzmr0000gn/T/error.dump.ddc14c42b05e40a5181262bd0b9ad027.log
It is probably important to mention that when I run ember --version command outside of the app directory it works, but when I run it inside app directory it crashes and gives error.
Just wanted to answer this small piece. When you run ember inside of a directory with a package.json that includes ember-cli it will run the version of ember installed there. This is really nice when you're moving between a few apps with different versions of ember-cli, but can be surprising in situations like this.
replace catch with catch (error)
just had the same problem and solved it by replacing catch with catch(error) so you need to add (error) next to each catch.
i needed to change this in about 10 files. so you gotta change every time and run it so you see the new location of the error. best of luck
Related
I have a freshly installed Ubuntu 22.04.1 LTS on which I have installed npm and docker.
When I want to start my NextJS web server (npm run dev) and the following error message appears:
niklas#srv-code01:~/Desktop/Code/Javascript/NextJS/website_01$ npm run dev
> website_01#0.1.0 dev
> next dev
/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/cli/next-dev.js:315
showAll: args["--show-all"] ?? false,
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.dev (/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/lib/commands.js:10:30)
at Object.<anonymous> (/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/bin/next:141:28)
at Module._compile (internal/modules/cjs/loader.js:999:30)
I can't see anything from the error message. What is the reason for the error? The error message also occurs with the following command: npm run start
I have the latest version of NPM installed.
Start of the NPM Development or Production Server on Port 3000
I had the same error and to resolve that I used the node version manager(nvm) to update my node.js version to 18.12.1.
To fix this, you need to follow the steps in this order-
Run this command to get the nvm.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Restart your terminal.
Install nvm- nvm install v18.12.1
Start nvm- npm run dev
You can use nvm list-remote to look at a complete list of the versions to choose from.
For more information, read here under option 3-
installing-node-using-the-node-version-manager
You can try init project by npx create-next-app#latest, not npx create-next-app. It works for me. Good luck~
I've been trying to run the code but it just shows this error i couldn't fix it because i'm not into coding that much i'm just trying to run the app
here's the error
Uncaught Error Error: Cannot find module 'node-fetch'
Require stack:
- c:\Users\As\Desktop\tiktok-downloader-main\index.js
at Module._resolveFilename (internal/modules/cjs/loader:956:15)
at Module._load (internal/modules/cjs/loader:804:27)
at Module.require (internal/modules/cjs/loader:1028:19)
at require (internal/modules/cjs/helpers:102:18)
at <anonymous> (c:\Users\As\Desktop\tiktok-downloader-main\index.js:6:15)
at Module._compile (internal/modules/cjs/loader:1126:14)
at Module._extensions..js (internal/modules/cjs/loader:1180:10)
at Module.load (internal/modules/cjs/loader:1004:32)
at Module._load (internal/modules/cjs/loader:839:12)
at executeUserEntryPoint (internal/modules/run_main:81:12)
at <anonymous> (internal/main/run_main_module:17:47)
Try looking for a file called package-lock.json in the tiktok-downloader-main folder. It could be in any of the sub folders. Once you find it, navigate to that folder in your terminal and run - npm install.
If you do not find the file called package-lock.json, look for yarn.lock file. If you find this file - in your terminal run yarn install.
These commands will work if you already have npm/yarn installed. For both of them, you will need nodejs installed.
Moreover, these commands have been tested on a Mac. Windows machine commands should be similar, but I do not gaurantee that these commands will work on windows machines as well.
I am trying to create a simple example Native addon for Electron. However, keep running into this version miss match issue. I have .nvmrc files for both my electron project and the addon project (using node 7.4.0).
Electron 1.6.7
Node 7.4.0
Nvm 0.33.2
NPM 4.0.5
The Error
App threw an error during load
Error: The module '/Users/mikepriest/source/Browser/exambrowser-electron/app/native/prebuilt/addon/build/Release/native_rt.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/mikepriest/source/Browser/exambrowser-electron/app/main.dev.js:20:10)
at Object.<anonymous> (/Users/mikepriest/source/Browser/exambrowser-electron/app/main.dev.js:217:3)
Tried solutions
1. Tried using
./node_modules/.bin/electron-rebuild
2. Tried rebuilding my addon
nvm use 7.4.0
npm rebuild
Still get the error.
Update: found this post, but solution didn't work for me either.
I'm currently using a package for running cross browser javascript tests called easy-sauce. In short, my package.json file calls that for the test command:
{
"scripts": {
"test": "easy-sauce"
}
}
When I'm using a Node 6 environment, and run npm test, all is well. However, the project I'm using it with still needs Node 5.6.0. When I run npm test in this environment, I see the following error:
/data/projects/easytest/node_modules/easy-sauce/lib/cli.js:114
function formatResult(result = {}) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/data/projects/easytest/node_modules/easy-sauce/bin/easy-sauce:6:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Is there a way to get this working within the Node 5.6.0 environment?
This error isn't related to the easy-sauce package, it has to do with your version of node.
According to node.green, default parameters were added in version 6.2.2
http://node.green/
Unfortunately you wont be able to run the code in node 5. Default parameters are in node 6.2, hence that error.
Option 1
Upgrade your version of node/npm. This is not always possible, depending on deployment environment.
Option 2
You need to use a transpiler (e.g. Babel) to convert the ES6 code to ES5 and reference the built script. This solution is the one you always have the power to do.
Option 3
Fork/update easy-sauce to include a transpiler to build an ES5 version (in the dist folder is a common destination). The package.json of the package can be directed to this location.
I installed "electron-packager" using npm and executed the command
electron-packager . Johnston --platform=darwin --arch=x64 --version=0.36.0
And then I when I run the "Johnston.app", this error showed up (I didn't even see the main window)
Uncaught Exception: Error: Cannot find module 'electron'
at Function.Module._resolveFilename (module.js:332:15)
at Function.Module._load (module.js:282:25)
at Module.require (module.js:361:17)
at require (module.js:380:17)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/app/main.js:3:18)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
at Module.load (module.js:351:32)
at Function.Module._load (module.js:306:12)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/atom.asar/browser/lib/init.js:104:10)
Is there any solutions? Thanks!
This likely has something to do with you having a different version of Electron installed on your machine that you are using to build with. In the folder for your app, run electron --version to get the version of electron that you have installed. Then, change the --version=0.36.0 to use whatever version you have installed.
If that doesn't fix it, then you should try rm -rf node_modules && npm install on your project. This will remove you node modules and then reinstall them all. If that doesn't work, please comment here and I will try to help again.