Angular JS Unit Testing: search module error - javascript

In the package.json file I have following dependencies :
"devDependencies": {
"bower": "^1.7.7",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-firefox-launcher": "^0.1.7",
"karma-jasmine": "^0.3.8",
"karma-junit-reporter": "^0.4.1",
"protractor": "^4.0.9"
}
And bower.json dependencies:
"dependencies": {
"angular": "~1.5.0",
"angular-route": "~1.5.0",
"angular-loader": "~1.5.0",
"angular-mocks": "~1.5.0",
"html5-boilerplate": "^5.3.0"
}
If I perform the command karma start karma.conf.js I'll have an error like this:
Error: Cannot find module 'jasmine-core'
at Function.Module._resolveFilename (module.js:469:15)
at Function.resolve (internal/module.js:27:19)
at initJasmine (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma-jasmine\lib\index.js:8:42)
at Array.invoke (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:75:15)
at Injector.get (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:48:43)
at C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\lib\server.js:143:20
at Array.forEach (native)
at Server._start (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\lib\server.js:142:21)
at Injector.invoke (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:75:15)
at Server.start (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\lib\server.js:103:18)
at Object.exports.run (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\lib\cli.js:280:26)
at Object.<anonymous> (C:\Users\Ema_Holub\AppData\Roaming\npm\node_modules\karma\bin\karma:3:23)
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)
What am I doing wrong?

Related

async function doesn't work in the gulpfile.babel.js

I have a 1gulpfile.babel.js with such code inside (where async-function should be assigned as an error handler for the gulp task):
// Load Node Modules/Plugins
import gulp from 'gulp';
import concat from 'gulp-concat';
// import myth from 'gulp-myth';
import uglify from 'gulp-uglify';
import jshint from 'gulp-jshint';
import imagemin from 'gulp-imagemin';
import connect from 'connect';
import serve from 'serve-static';
import browsersync from 'browser-sync';
import postcss from 'gulp-postcss';
import cssnext from 'postcss-cssnext';
import cssnano from 'cssnano';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import babelify from 'babelify';
import plumber from 'gulp-plumber';
import del from 'del';
import config from './config.json';
import sourcemaps from 'gulp-sourcemaps';
import regeneratorRuntime from "regenerator-runtime";
// Error Handler
async function onError(err) {
console.log('Name:', err.name);
console.log('Reason:', err.reason);
console.log('File:', err.file);
console.log('Line:', err.line);
console.log('Column:', err.column);
}
var cssFiles = ['app/css/main.css', 'app/css/*.css'];
// Styles Task
gulp.task('styles', () => {
return gulp.src(cssFiles)
.pipe(plumber(
{
errorHandler: onError
}
))
.pipe(concat('all.css'))
.pipe(postcss([
cssnext(),
cssnano()
]))
.pipe(plumber.stop())
.pipe(gulp.dest(config.css.dest));
});
also in this (root project) directory is package.json file:
{
"name": "gulp-book",
"version": "1.0.0",
"description": "A simple gulp project...",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "ms",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.2.5",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"babelify": "^8.0.0",
"beeper": "^3.0.0",
"browser-sync": "^2.27.9",
"browserify": "^17.0.0",
"connect": "^3.7.0",
"cssnano": "^5.1.7",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^7.1.0",
"gulp-jshint": "^2.1.0",
"gulp-plumber": "^1.2.1",
"gulp-postcss": "^9.0.1",
"gulp-sass": "^5.1.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-uglify": "^3.0.2",
"jshint": "^2.13.4",
"postcss-cssnext": "^3.1.1",
"regenerator-runtime": "^0.13.9",
"serve-static": "^1.15.0",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
}
}
and .babelrc file:
{
"presets": [ "es2015", "stage-0" ]
}
When I'm executing gulp --gulpfile 1gulpfile.babel.js styles command I'm getting and error:
[18:55:28] Requiring external module babel-register
TypeError: Cannot read properties of undefined (reading 'default')
at C:\Users\Sergey\Documents\code\web\Getting-Started-with-Gulp-Second-Edition\gulpfile.babel.js:5:69
at Object.<anonymous> (C:\Users\Sergey\Documents\code\web\Getting-Started-with-Gulp-Second-Edition\gulpfile.babel.js:28:2)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at loader (C:\Users\Sergey\Documents\code\web\Getting-Started-with-Gulp-Second-Edition\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.<computed> [as .js] (C:\Users\Sergey\Documents\code\web\Getting-Started-with-Gulp-Second-Edition\node_modules\babel-register\lib\node.js:154:7)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at requireOrImport (C:\Users\Sergey\AppData\Roaming\npm\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11)
So the question is - what is the error and how I can handle with it?

Expo SDK 44 upgrade ERROR - App.js: [BABEL]: Unexpected token '.'

I have recently upgraded my app from SDK 40 to SDK 44 and came across this error App.js: [BABEL]: Unexpected token '.' (While processing: /Users/user/path/to/project/node_modules/babel-preset-expo/index.js)
Error Stack Trace:
App.js: [BABEL]: Unexpected token '.' (While processing: /Users/user/path/to/project/node_modules/babel-preset-expo/index.js)
/Users/user/path/to/project/node_modules/babel-preset-expo/index.js:48
...(options?.jsxRuntime !== 'classic' && {
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:931:16)
at Module._compile (internal/modules/cjs/loader.js:979:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at loadCjsDefault (/Users/user/path/to/project/node_modules/#babel/core/lib/config/files/module-types.js:85:18)
at loadCjsOrMjsDefault (/Users/user/path/to/project/node_modules/#babel/core/lib/config/files/module-types.js:57:16)
Here is my babel.config.js:
return {
presets: ['babel-preset-expo', { jsxRuntime: 'automatic' }],
plugins: [
['inline-dotenv'],
['.....']
]
}
Here is my package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#babel/plugin-transform-react-jsx": "^7.16.5",
"#react-native-async-storage/async-storage": "~1.15.0",
"#react-native-community/art": "^1.2.0",
"#react-native-community/datetimepicker": "4.0.0",
"#react-native-community/masked-view": "0.1.10",
"#react-native-community/netinfo": "7.1.3",
"#react-native-community/push-notification-ios": "^1.2.2",
"#react-native-community/slider": "4.1.12",
"#react-navigation/native": "^5.1.4",
"aws-amplify": "^3.3.1",
"aws-amplify-react-native": "^4.2.6",
"axios": "^0.19.2",
"expo": "^44.0.0",
"expo-app-loading": "~1.3.0",
"expo-barcode-scanner": "~11.2.0",
"expo-camera": "~12.1.0",
"expo-constants": "~13.0.0",
"expo-font": "~10.0.4",
"expo-linking": "~3.0.0",
"expo-mail-composer": "~11.1.0",
"expo-notifications": "~0.14.0",
"expo-permissions": "~13.1.0",
"expo-secure-store": "~11.1.0",
"expo-sqlite": "~10.1.0",
"expo-updates": "~0.11.2",
"expo-web-browser": "~10.1.0",
"file-saver": "^2.0.2",
"jsbarcode": "^3.11.3",
"link": "^0.1.5",
"metro-config": "^0.64.0",
"npm": "^8.3.0",
"qs": "^6.9.4",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-44.0.0.tar.gz",
"react-native-barcode-expo": "^1.1.1",
"react-native-elements": "^3.2.0",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "~2.1.0",
"react-native-modal": "^11.5.6",
"react-native-modal-datetime-picker": "^8.6.0",
"react-native-paper": "^3.10.1",
"react-native-push-notification": "^3.5.2",
"react-native-reanimated": "~2.3.1",
"react-native-router-flux": "^4.2.0",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "12.1.1",
"react-native-web": "0.17.1",
"react-navigation-animated-switch": "^0.6.4",
"react-navigation-drawer": "^2.4.11",
"react-navigation-header-buttons": "^3.0.5",
"react-router-dom": "^6.0.0-alpha.3",
"yarn": "^1.22.17"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.9.2",
"#react-native-community/eslint-config": "^0.0.7",
"babel-jest": "^25.1.0",
"babel-plugin-inline-dotenv": "^1.6.0",
"babel-preset-expo": "9.0.1",
"eslint": "^6.8.0",
"expo-cli": "^5.0.2",
"jest": "^26.6.3",
"jest-expo": "^44.0.0",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "^16.13.1"
},
"private": true
}
Any help will be greatly appreciated.
can you give your
package.json
node version
I think that's because of the babel issue / your node version, because it cannot transpile the optional chaining https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
maybe tried using latest LTS node version? because as far as I know, the latest LTS node version already support optional chaining
Just to let you know, it's a bug in babel-preset-expo when you are using Node 12.
Optional chainning is not supported in node12 and can be easily replaced with extra checks
https://github.com/expo/expo/pull/15545
From what I can see, Expo SDK 44 is still in beta.
The Error Stack Trace reads that newer syntax (in this case the optional chaining operator ?.) isn't being transpiled by Babel which causes the failure.
Simply downgrading to the stable SDK 43 should solve all issues.
P.S: This error has been reported to Expo already by the beta testers.
If you use expo v44 you have to update babel-preset-expo dev dependency to v9.0.2:
"babel-preset-expo": "9.0.2",
Downgrading to SDK 43.0.0 worked fine for me:
expo update 43.0.0

Error when import firebase-functions-test when testing with mocha

I am trying to setup a Firebase Cloud Functions repo to run mocha test. However, it throws the following error when I use import * as firebase from "firebase-functions-test"; or const firebase = require("firebase-functions-test")();. You can see in my code that I haven't even called the actual firebase functions yet so I think this a setup issue.
Question: What change do I need to make mocha test running for Firebase Functions testing using import syntax?
Working test code
import { assert } from "chai";
describe("Sanity Check", () => {
it("should pass", () => {
assert.equal(0, 0);
});
});
Failed Test Code using require
const test = require("firebase-functions-test")();
import { assert } from "chai";
describe("Sanity Check", () => {
it("should pass", () => {
assert.equal(0, 0);
test.cleanup();
});
});
Failed code using import
import * as firebase from "firebase-functions-test";
import { assert } from "chai";
const test = firebase();
describe("Sanity Check", () => {
it("should pass", () => {
assert.equal(0, 0);
test.cleanup();
});
});
Error for the failure
> functions# test /Users/cupidchan/temp/functions
> mocha -r ts-node/register test/**/*.spec.ts
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/encoder' is not defined by "exports" in /Users/cupidchan/temp/functions/node_modules/firebase-functions/package.json
at new NodeError (internal/errors.js:322:7)
at throwExportsNotFound (internal/modules/esm/resolve.js:322:9)
at packageExportsResolve (internal/modules/esm/resolve.js:545:3)
at resolveExports (internal/modules/cjs/loader.js:450:36)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/cupidchan/temp/functions/node_modules/#cspotcode/source-map-support/source-map-support.js:679:30)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/cupidchan/temp/functions/node_modules/firebase-functions-test/lib/providers/firestore.js:26:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/cupidchan/temp/functions/node_modules/firebase-functions-test/lib/features.js:9:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at module.exports (/Users/cupidchan/temp/functions/node_modules/firebase-functions-test/lib/index.js:30:20)
at Object.<anonymous> (/Users/cupidchan/temp/functions/test/index.spec.ts:9:14)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Module.m._compile (/Users/cupidchan/temp/functions/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .ts] (/Users/cupidchan/temp/functions/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.exports.requireOrImport (/Users/cupidchan/temp/functions/node_modules/mocha/lib/nodejs/esm-utils.js:56:20)
at async Object.exports.loadFilesAsync (/Users/cupidchan/temp/functions/node_modules/mocha/lib/nodejs/esm-utils.js:88:20)
at async singleRun (/Users/cupidchan/temp/functions/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at async Object.exports.handler (/Users/cupidchan/temp/functions/node_modules/mocha/lib/cli/run.js:374:5)
npm ERR! Test failed. See above for more details.
package.json
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"test": "mocha -r ts-node/register test/**/*.spec.ts --reporter spec"
},
"engines": {
"node": "14"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"#types/chai": "^4.2.22",
"#types/mocha": "^9.0.0",
"#types/node": "^16.11.11",
"#typescript-eslint/eslint-plugin": "^3.9.1",
"#typescript-eslint/parser": "^3.8.0",
"chai": "^4.3.4",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^4.0.0",
"esm": "^3.2.25",
"firebase-functions-test": "^0.2.3",
"mocha": "^9.1.3",
"prettier": "^2.5.0",
"ts-node": "^10.4.0",
"typescript": "^3.8.0"
},
"private": true
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": ["src", "test"]
}
This error should be resolved after specifying the latest version of the
firebase-functions, v3.16.0, and
firebase-functions-test, v0.3.3.

Error: Cannot find module nuxt.js, why my app don't start?

I´ve got this error when try to run npm run dev after installed the dependencies and i cant find why. Help me please.
I tried some things that found around the internet but none of that worked
plusholidays-app#1.0.0 dev
> nuxt
"F\plusholidays-app\node_modules\.bin\" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:\Users\anyel\Documents\src\nuxt\bin\nuxt.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Here is the package.json
{
"name": "plusholidays-app",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.1",
"#nuxtjs/moment": "^1.6.1",
"#nuxtjs/proxy": "^2.1.0",
"apexcharts": "^3.26.0",
"core-js": "^3.9.0",
"js-cookie": "^2.2.1",
"leaflet": "^1.7.1",
"lodash.clonedeep": "^4.5.0",
"nuxt": "^2.15.2",
"nuxt-i18n": "^6.21.1",
"vue-advanced-cropper": "^1.3.2",
"vue-apexcharts": "^1.6.0",
"vue-the-mask": "^0.11.1",
"vue2-leaflet": "^2.6.0"
},
"devDependencies": {
"#nuxtjs/vuetify": "^1.11.3",
"babel-eslint": "^10.1.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^8.1.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.6.0",
"prettier": "^2.2.1"
}
}
I really want to understand what is going on here, but I'm at a bit of a loss as to where to look next. Any suggestions?
Try and install nuxt-start package.
This is what I used to solve a very similar challenge (On Production)
where you node_modules? C:\Users\anyel\Documents\src\nuxt\bin\nuxt.js
try path: script: './node_modules/nuxt/bin/nuxt.js',

Node NPM SyntaxError: Unexpected token import [duplicate]

This question already has answers here:
ES2015 "import" not working in node v6.0.0 with with --harmony_modules option
(4 answers)
Closed 5 years ago.
I'm running into an issue that seems to be very popular with Node / NPM
None of my search results seems to address my issue exactly...
I'm using Restify & NodeJs...but a simple npm run start produces the following error...
import logger from 'src/modules/amLogger.js';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
My packake.json file:
{
"name": "example",
"version": "0.0.1",
"author": "Me#me.com",
"engines": {
"node": ">=8.2.1",
"npm": ">=5.3.0"
},
"license": "MIT",
"dependencies": {
"ascii-art": "^1.4.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-generator": "^6.25.0",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-syntax-trailing-function-commas": "^6.20.0",
"babel-plugin-transform-async-to-module-method": "^6.16.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
"babel-plugin-transform-export-extensions": "^6.8.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babel-register": "^6.18.0",
"canvas": "^1.6.6",
"chalk": "^2.0.1",
"compression": "^1.7.0",
"documentation": "^5.0.1",
"dotenv": "^4.0.0",
"lodash": "^4.17.4",
"pretty-error": "^2.1.1",
"restify": "^5.0.1",
"restify-error": "^1.0.0",
"restify-plugins": "^1.6.0",
"socket.io": "^2.0.3",
"util": "^0.10.3",
"winston": "^2.3.1"
},
"devDependencies": {
"ascii-art": "^1.4.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-generator": "^6.25.0",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-syntax-trailing-function-commas": "^6.20.0",
"babel-plugin-transform-async-to-module-method": "^6.16.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
"babel-plugin-transform-export-extensions": "^6.8.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babel-register": "^6.18.0",
"canvas": "^1.6.6",
"chalk": "^2.0.1",
"compression": "^1.7.0",
"documentation": "^5.0.1",
"dotenv": "^4.0.0",
"es6-promise": "^4.1.1",
"lodash": "^4.17.4",
"pretty-error": "^2.1.1",
"restify": "^5.0.1",
"restify-error": "^1.0.0",
"restify-plugins": "^1.6.0",
"socket.io": "^2.0.3",
"util": "^0.10.3",
"winston": "^2.3.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"am:version": "/bin/sh scripts/display.sh",
"am:pretty-error": "node --require pretty-error/start am.js",
"am:start": "/bin/sh scripts/display.sh && node am.js",
"start": "node am.js"
},
"description": "example",
"main": "am.js"
}
Here is my am.js file
'use strict';
require('dotenv').config();
import logger from 'src/modules/amLogger.js';
import chalk from 'chalk';
import util from 'util';
/**
* Module Dependencies
*/
const restify = require('restify'),
winston = require('winston'),
errs = require('restify-errors'),
art = require('ascii-art'),
compression = require('compression');
// create the Restify Server
const server = restify.createServer({
name: 'example',
version: 'v0.0.1',
...
The error is happening at import logger from 'src/modules/amLogger.js'; however if I comment out this line the error simply moves to the next import statement -- I've also tried running this without the 'use strict';
What am I missing?
Node doesnt support yet es6 imports here you have an article that explains it
https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c

Categories