I just cloned a repository ( a React Native project) from Github, ran npm install and then npm start.
Then instead of running the metro bundler, it throws the following error:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './lib/source-map-generator'
Require stack:
- D:\ProjectX\node_modules\snapdragon\node_modules\source-map\source-map.js
- D:\ProjectX\node_modules\snapdragon\lib\utils.js
- D:\ProjectX\node_modules\snapdragon\lib\compiler.js
- D:\ProjectX\node_modules\snapdragon\index.js
- D:\ProjectX\node_modules\sane\node_modules\braces\lib\braces.js
- D:\ProjectX\node_modules\sane\node_modules\braces\index.js
- D:\ProjectX\node_modules\sane\node_modules\micromatch\index.js
- D:\ProjectX\node_modules\sane\node_modules\anymatch\index.js
- D:\ProjectX\node_modules\sane\src\common.js
- D:\ProjectX\node_modules\jest-haste-map\build\lib\WatchmanWatcher.js
- D:\ProjectX\node_modules\jest-haste-map\build\index.js
- D:\ProjectX\node_modules\metro-core\src\errors\AmbiguousModuleResolutionError.js
- D:\ProjectX\node_modules\metro-core\src\index.js
- D:\ProjectX\node_modules\metro\src\node-haste\DependencyGraph.js
- D:\ProjectX\node_modules\metro\src\Bundler.js
- D:\ProjectX\node_modules\metro\src\IncrementalBundler.js
- D:\ProjectX\node_modules\metro\src\Server.js
- D:\ProjectX\node_modules\metro\src\shared\output\bundle.js
- D:\ProjectX\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- D:\ProjectX\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- D:\ProjectX\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- D:\ProjectX\node_modules\#react-native-community\cli-plugin-metro\build\commands\index.js
- D:\ProjectX\node_modules\#react-native-community\cli-plugin-metro\build\index.js
- D:\ProjectX\node_modules\react-native\node_modules\#react-native-community\cli\build\commands\index.js
- D:\ProjectX\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js
- D:\ProjectX\node_modules\react-native\cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
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.<anonymous> (D:\ProjectX\node_modules\snapdragon\node_modules\source-map\source-map.js:6:30)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\ProjectX\\node_modules\\snapdragon\\node_modules\\source-map\\source-map.js',
'D:\\ProjectX\\node_modules\\snapdragon\\lib\\utils.js',
'D:\\ProjectX\\node_modules\\snapdragon\\lib\\compiler.js',
'D:\\ProjectX\\node_modules\\snapdragon\\index.js',
'D:\\ProjectX\\node_modules\\sane\\node_modules\\braces\\lib\\braces.js',
'D:\\ProjectX\\node_modules\\sane\\node_modules\\braces\\index.js',
'D:\\ProjectX\\node_modules\\sane\\node_modules\\micromatch\\index.js',
'D:\\ProjectX\\node_modules\\sane\\node_modules\\anymatch\\index.js',
'D:\\ProjectX\\node_modules\\sane\\src\\common.js',
'D:\\ProjectX\\node_modules\\jest-haste-map\\build\\lib\\WatchmanWatcher.js',
'D:\\ProjectX\\node_modules\\jest-haste-map\\build\\index.js',
'D:\\ProjectX\\node_modules\\metro-core\\src\\errors\\AmbiguousModuleResolutionError.js',
'D:\\ProjectX\\node_modules\\metro-core\\src\\index.js',
'D:\\ProjectX\\node_modules\\metro\\src\\node-haste\\DependencyGraph.js',
'D:\\ProjectX\\node_modules\\metro\\src\\Bundler.js',
'D:\\ProjectX\\node_modules\\metro\\src\\IncrementalBundler.js',
'D:\\ProjectX\\node_modules\\metro\\src\\Server.js',
'D:\\ProjectX\\node_modules\\metro\\src\\shared\\output\\bundle.js',
'D:\\ProjectX\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
'D:\\ProjectX\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
'D:\\ProjectX\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
'D:\\ProjectX\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
'D:\\ProjectX\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\index.js',
'D:\\ProjectX\\node_modules\\react-native\\node_modules\\#react-native-community\\cli\\build\\commands\\index.js',
'D:\\ProjectX\\node_modules\\react-native\\node_modules\\#react-native-community\\cli\\build\\index.js',
'D:\\ProjectX\\node_modules\\react-native\\cli.js'
]
}
Does anybody know how to solve the above issue?
Thanks in advance.
Try removing node_modules and repeat the npm install or yarn.
If that still doesn’t work, maybe try removing package-lock.json/yarn.lock and repeat the above.
Related
I had a simple Serverless website running in AWS lambda using node serverless deploy, I then added more stuff to the site and updated to the latest version of serverless, now when I deploy the site and visit the URL I get:
{"message": "Internal server error"}
When I visit the lambda console I get:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module './dist/server'",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module './dist/server'",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:45:30)",
" 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)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)",
" at startup (internal/bootstrap/node.js:283:19)"
]
}
Any idea how to fix this?
More Info
Based on #Amit Baranes comment below which references this SO post here is a Angular site. I don't quite understand what I need to change the handler name to to match my site structure. I am not bundling the files into a .zip myself, but am running the serverless deploy command through node:
Here is the website serverless.yml
# generated by #ng-toolkit/serverless
service: serverless-site
plugins:
- serverless-apigw-binary
provider:
name: aws
runtime: nodejs10.x
memorySize: 192
timeout: 10
stage: production
region: us-east-1
package:
exclude:
- src/**
- node_modules/**
- firebug-lite/**
- e2e/**
- coverage/**
- '!node_modules/aws-serverless-express/**'
- '!node_modules/binary-case/**'
- '!node_modules/type-is/**'
- '!node_modules/media-typer/**'
- '!node_modules/mime-types/**'
- '!node_modules/mime-db/**'
custom:
apigwBinary:
types:
- '*/*'
functions:
api:
handler: lambda.universal
events:
- http: ANY {proxy+}
- http: ANY /
Here is my project file structure (starting inside the src directory) for the website.
Here is the website lambda function when it is deployed:
Since the function didn't have a server.js. I attempted to create is by modifying server.ts and putting it in the folder with no luck:
// generated by Paul
//import 'zone.js/dist/zone-node';
//import 'reflect-metadata';
var express =require('express');
var cors= require('cors');
var compression =require('compression');
var join=require('path').join;
export const app = express();
app.use(compression());
app.use(cors());
const DIST_FOLDER = join(process.cwd(), 'dist/serverless-site');
app.get('*.*', express.static(join(DIST_FOLDER), {
maxAge: '1y'
}));
app.get('/*', (req, res) => {
res.sendFile(join(DIST_FOLDER + '/index.html'));
});
So it seems that server.js is not created in the dist folder.
I got it working by running npm run build:server:prod before serverless deploy
The relevant line in my package.json looks as follows:
"build:server:serverless": "webpack --config webpack.server.config.js"
This is probably not the right way to do it, but it solved the issue of not finding ./dist/server and got me to the next error:
{
"errorType": "TypeError",
"errorMessage": "express is not a function",
"stack": [
"TypeError: express is not a function",
" at Object.<anonymous> (/var/task/dist/server.js:9231:15)",
" at __webpack_require__ (/var/task/dist/server.js:21:30)",
" at /var/task/dist/server.js:85:18",
" at Object.<anonymous> (/var/task/dist/server.js:88:10)",
" 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)",
" at Module.require (internal/modules/cjs/loader.js:692:17)"
]
}
I got the express error fixed by setting esModuleInterop = false in the tsconfig file, thanks to AWS Serverless Lambda + Angular - TypeError: express is not a function
I do see you are using the ng-toolkit package in order to provide universal + serverless for your Angular App.
Based on that, I do think you are receiving such error due to either bad config on latest version of the package, which includes some bugs on the server file along with mismatch with the Angular/Universal package.
I do recommend checking out my sample repo in the meantime Example Angular ng-toolkit, which already fixes that.
Just to point out: this is caused by webpack.config option externals which was introduced on latest express-engine schematic of the Angular Universal packages. Commenting that line, will fix your issue.
The reason is still unknown for me at the moment but hopefully I will bring my findings on this topic.
Cheers!
Deploying generated app with JHipster(version: 5.8.2) to AWS using aws-containers sub-generator gives ERROR! Cannot find module 'aws-sdk'
$ jhipster import-jdl blog.jh.
Content of blog.jh:
application {
config {
baseName blog,
applicationType monolith,
packageName org.jhipster.blog,
authenticationType jwt,
prodDatabaseType mysql,
cacheProvider no,
enableHibernateCache false,
buildTool maven,
clientFramework angularX,
useSass false,
testFrameworks [protractor]
}
entities *
}
entity Blog {
name String required minlength(3),
handle String required minlength(2)
}
entity Entry {
title String required,
content TextBlob required,
date Instant required
}
entity Tag {
name String required minlength(2)
}
relationship ManyToOne {
Blog{user(login)} to User,
Entry{blog(name)} to Blog
}
relationship ManyToMany {
Entry{tag(name)} to Tag{entry}
}
paginate Entry, Tag with infinite-scroll
$ jhipster aws-containers
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:aws-containers
INFO! Options: from-cli: true
ERROR! Cannot find module 'aws-sdk'
{ Error: Cannot find module 'aws-sdk'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/generator-jhipster/generators/aws-containers/lib/ssm.js:19:13)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3) code: 'MODULE_NOT_FOUND' }
$ npm install aws-sdk gave
ERROR! Cannot find module 'ora'
$ npm install ora
And it came to:
$ jhipster aws-containers
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:aws-containers
INFO! Options: from-cli: true
This AWS generator will help you deploy your JHipster app as a Docker container on AWS.
✔ Docker is installed
Installing AWS dependencies
✔ AWS credentials using profile default.
events.js:174
throw er; // Unhandled 'error' event
^
TypeError: ora is not a function
at spinner (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/generator-jhipster/generators/aws-containers/aws-client.js:120:21)
at Object.listRegions (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/generator-jhipster/generators/aws-containers/aws-client.js:142:12)
at module.exports.fetchRegion (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/generator-jhipster/generators/aws-containers/index.js:159:22)
at Object.<anonymous> (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/yeoman-generator/lib/index.js:418:27)
at /home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/run-async/index.js:25:25
at new Promise (<anonymous>)
at /home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/run-async/index.js:24:19
at self.env.runLoop.add.completed (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/yeoman-generator/lib/index.js:419:13)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
Emitted 'error' event at:
at Immediate.setImmediate (/home/stane/Work/Lab/JHipster/blog.aws-containers/node_modules/yeoman-generator/lib/index.js:427:22)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:120:23)
I have recently started Lambda function development on AWS. When try to import a JavaScript file I am getting the following error,and I have also used DynamoDb
module initialization error: TypeError
at Object.<anonymous> (/var/task/index.js:14:16)
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)
at require (internal/module.js:20:19)
This is my code which I have zipped along with node modules and package.json
const alexaSDK = require('alexa-sdk');
const awsSDK = require('aws-sdk');
const promisify = require('es6-promisify');
awsSDK.config.update({
region: "us-west"
});
//const appId = 'REPLACE WITH YOUR SKILL APPLICATION ID';
const recipesTable = 'Recipes';
const docClient = new awsSDK.DynamoDB.DocumentClient();
// convert callback style functions to promises
const dbScan = promisify(docClient.scan, docClient);
const dbGet = promisify(docClient.get, docClient);
const dbPut = promisify(docClient.put, docClient);
const dbDelete = promisify(docClient.delete, docClient);
I have installed everything that is needed.Could anyone help with this error.
Running the iOS runscript causes the following error. Any advice?
This happens to the sample project
/bin/sh -c /Users/aryan.ghassemi/Library/Developer/Xcode/DerivedData/FrontPage-djowwaikrpnoghhjhlxriwamylsv/Build/Intermediates/FrontPage.build/Debug-iphonesimulator/FrontPage.build/Script-9F672F2E1DB0053600974171.sh
/Users/aryan.ghassemi/.nvm/versions/node/v4.2.6/lib/node_modules/apollo-codegen/lib/cli.js:41
const [name, value] = header.split(/\s*:\s*/);
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
The version of Apollo.framework in your project requires apollo-codegen 0.15, but an unknown older version seems to be installed. Installing...
/Users/aryan.ghassemi/.nvm/versions/node/v4.2.6/bin/apollo-codegen -> /Users/aryan.ghassemi/.nvm/versions/node/v4.2.6/lib/node_modules/apollo-codegen/lib/cli.js
+ apollo-codegen#0.15.2
updated 1 package in 1.363s
++ exec apollo-codegen generate ./PostListViewController.graphql ./PostTableViewCell.graphql --schema schema.json --output API.swift
/Users/aryan.ghassemi/.nvm/versions/node/v4.2.6/lib/node_modules/apollo-codegen/lib/cli.js:41
const [name, value] = header.split(/\s*:\s*/);
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Command /bin/sh failed with exit code 1
Script was running on an older version of node, updating to 6.9 fixed the issue
I'm currently developing a C++ addon for NodeJS using the abstraction layer Nan. I would like to make a PostgreSQL request from this addon. But I get the following error:
module.js:597
return process.dlopen(module, path._makeLong(filename));
^
Error: ....cpp/build/Release/MyModule.node: undefined symbol: _ZTVN4pqxx14connect_directE
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
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)
at require (internal/module.js:20:19)
at Object.<anonymous> (...cpp/test.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
Here is my binding.gyp:
{
"targets": [
{
"target_name": "MyModule",
"sources": [ "Main.cpp"],
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"cflags": [
"-fexceptions",
"-lpq",
"-lpqxx"
],
"cflags_cc": [
"-fexceptions",
"-lpq",
"-lpqxx"
]
}
]
}
And my Main.cpp file
#include <nan.h>
#include <iostream>
#include <pqxx/pqxx>
using namespace Nan;
using namespace v8;
using namespace std;
using namespace pqxx;
NAN_METHOD(MyModule) {
// Database connection
connection C(
"dbname = ... \
user = ... \
password = ... \
hostaddr = 127.0.0.1 \
port = 5432");
}
NAN_MODULE_INIT(Init) {
Nan::Set(target, New<String>("MyModule").ToLocalChecked(),
GetFunction(New<FunctionTemplate>(MyModule)).ToLocalChecked());
}
NODE_MODULE(parser, Init)
I'm stuck with this error and I didn't find any solution on the web. I would be nice if someone could help!
dlopen tries to load a shared library. However, this library misses a symbol, _ZTVN4pqxx14connect_directE. To decode it:
$ c++filt _ZTVN4pqxx14connect_directE`
vtable for pqxx::connect_direct
Therefore, you need to link a library to your library (addon), which has this symbol. (The postgres driver?)
Make sure your build system doesn't delay the linking, and the lib appears when your run ldd your_addon. If the driver is installed to a non-standard directory, you can experiment with setting LD_LIBRARY_PATH, as a temporary solution.