Cannot use/import npm packages in Meteor - meteor
I am not able to do:
import SimpleSchema from 'simpl-schema';
or to import any other npm package with this command. I have already installed the package via meteor npm install --save simpl-schema.
I have also tried to import other npm dependencies like:
import moment from 'moment';
Therefore, I think that I generally missed something important to be able to require NPM packages in my client-side code or that I am using a wrong structure?
I get the error:
Uncaught SyntaxError: Unexpected identifier
in the browser console.
Edit
I have called meteor npm install before running the app.
If I code this line import moment from 'moment'; on a server side js-file, I get the following error:
app\server\startup\profilemanagement.js:1
(function(NPM,Assets){(function(){import moment from 'moment';
SyntaxError: Unexpected token import at C:...meteor\local\build\programs\server\boot.js:392:18 at
Array.forEach () at Function..each..forEach
(C:...meteor\packages\meteor-tool\1.6.0:1\mt-os.windows.x86_64\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11) at C:...meteor\local\build\programs\server\boot.js:220:5 at
C:...meteor\local\build\programs\server\boot.js:463:5 at
Function.run
(C:...meteor\local\build\programs\server\profile.js:510:12) at
C:...meteor\local\build\programs\server\boot.js:462:11
I am not sure if I installed the babel packages correctly. I think something went wrong there. Here is my package.json:
{
"dependencies": {
"abbrev": "^1.1.0",
"addressparser": "^1.0.1",
"ajv": "^5.2.2",
"ansi-regex": "^3.0.0",
"aproba": "^1.2.0",
"are-we-there-yet": "^1.1.4",
"asn1": "^0.2.3",
"assert-plus": "^1.0.0",
"asynckit": "^0.4.0",
"aws-sign2": "^0.7.0",
"aws4": "^1.6.0",
"babel-runtime": "^6.26.0",
"balanced-match": "^1.0.0",
"bcrypt": "^1.0.3",
"bcrypt-pbkdf": "^1.0.1",
"block-stream": "0.0.9",
"boom": "^5.2.0",
"brace-expansion": "^1.1.8",
"buildmail": "^4.0.1",
"caseless": "^0.12.0",
"chart.js": "^2.7.0",
"chartjs-color": "^2.2.0",
"cloudinary": "^1.9.0",
"co": "^4.6.0",
"code-point-at": "^1.1.0",
"color-convert": "^1.9.0",
"color-name": "^1.1.3",
"combined-stream": "^1.0.5",
"concat-map": "0.0.1",
"console-control-strings": "^1.1.0",
"core-js": "^2.5.1",
"core-util-is": "^1.0.2",
"cryptiles": "^3.1.2",
"dashdash": "^1.14.1",
"debug": "^3.0.1",
"deep-extend": "^0.5.0",
"delayed-stream": "^1.0.0",
"delegates": "^1.0.0",
"ecc-jsbn": "^0.1.1",
"extend": "^3.0.1",
"extsprintf": "^1.3.0",
"fast-deep-equal": "^1.0.0",
"fontawesome": "^4.7.2",
"forever-agent": "^0.6.1",
"form-data": "^2.3.1",
"fs.realpath": "^1.0.0",
"fstream": "^1.0.11",
"fstream-ignore": "^1.0.5",
"gauge": "^2.7.4",
"getpass": "^0.1.7",
"glob": "^7.1.2",
"graceful-fs": "^4.1.11",
"har-schema": "^2.0.0",
"har-validator": "^5.0.3",
"has-unicode": "^2.0.1",
"hawk": "^6.0.2",
"hoek": "^4.2.0",
"http-signature": "^1.2.0",
"iconv-lite": "^0.4.19",
"inflight": "^1.0.6",
"inherits": "^2.0.3",
"ini": "^1.3.4",
"is-fullwidth-code-point": "^2.0.0",
"is-typedarray": "^1.0.0",
"isarray": "^2.0.2",
"isstream": "^0.1.2",
"jasny-bootstrap": "^3.1.3",
"jodid25519": "^1.0.2",
"jsbn": "^1.1.0",
"json-schema": "^0.2.3",
"json-schema-traverse": "^0.3.1",
"json-stable-stringify": "^1.0.1",
"json-stringify-safe": "^5.0.1",
"jsonify": "0.0.0",
"jsprim": "^1.4.1",
"libbase64": "^0.2.0",
"libmime": "^3.1.0",
"libqp": "^1.1.0",
"lodash": "^4.17.4",
"mailcomposer": "^4.0.2",
"meteor-node-stubs": "^0.2.11",
"mime-db": "^1.30.0",
"mime-types": "^2.1.17",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"moment": "^2.18.1",
"ms": "^2.0.0",
"nan": "^2.7.0",
"node-pre-gyp": "^0.6.37",
"nodemailer": "^4.1.0",
"nodemailer-fetch": "^2.1.0",
"nodemailer-shared": "^2.0.0",
"nopt": "^4.0.1",
"npmlog": "^4.1.2",
"number-is-nan": "^1.0.1",
"oauth-sign": "^0.8.2",
"object-assign": "^4.1.1",
"object-inspect": "^1.3.0",
"object-keys": "^1.0.11",
"once": "^1.4.0",
"os-homedir": "^1.0.2",
"os-tmpdir": "^1.0.2",
"osenv": "^0.1.4",
"path-is-absolute": "^1.0.1",
"path-parse": "^1.0.5",
"performance-now": "^2.1.0",
"process-nextick-args": "^1.0.7",
"punycode": "^2.1.0",
"q": "^1.5.0",
"qs": "^6.5.1",
"rc": "^1.2.1",
"readable-stream": "^2.3.3",
"regenerator-runtime": "^0.11.0",
"request": "^2.82.0",
"resolve": "^1.4.0",
"resumer": "0.0.0",
"rimraf": "^2.6.2",
"safe-buffer": "^5.1.1",
"semver": "^5.4.1",
"set-blocking": "^2.0.0",
"signal-exit": "^3.0.2",
"sntp": "^2.0.2",
"sshpk": "^1.13.1",
"string-width": "^2.1.1",
"string.prototype.trim": "^1.1.2",
"string_decoder": "^1.0.3",
"stringstream": "0.0.5",
"strip-ansi": "^4.0.0",
"strip-json-comments": "^2.0.1",
"sweetalert": "^1.1.3",
"tape": "^4.8.0",
"tar": "^4.0.1",
"tar-pack": "^3.4.0",
"through": "^2.3.8",
"tough-cookie": "^2.3.2",
"tunnel-agent": "^0.6.0",
"tweetnacl": "^1.0.0",
"uid-number": "0.0.6",
"util-deprecate": "^1.0.2",
"uuid": "^3.1.0",
"verror": "^1.10.0",
"wide-align": "^1.1.2",
"wow.js": "^1.2.2",
"wrappy": "^1.0.2",
"yallist": "^3.0.2"
}
}
Second edit
It seems to be that (maybe since the last update?) I have a major issue with the meteor installation and its npm dependencies. I am not able to create a new meteor project due to this error:
Error: Error: Could not install npm dependencies for test-packages:
Command failed: C:\WINDOWS\system32\cmd.exe /c
C:\Users...\AppData\Local.meteor\packages\meteor-tool\1.6.0._1\mt-os.windows.x86_64\dev_bundle\bin\npm.cmd
install npm ERR! code ENOGIT npm ERR! No git binary found in $PATH npm
ERR! npm ERR! Failed using git. npm ERR! Please check if you have git
installed and in your PATH.
You can check this error here:
https://github.com/meteor/meteor/issues/8585. It tells that me that no Npm dependencies can be installed because of not finding the Git-path.
However, the solutiuon to reinstall Git did not work for me. So, I think something went generally wrong since the last meteor update. Maybe the only solution is to reinstall meteor completely or use an older version? I started this project from my computer with an older meteor version and uninstalling and reinstalling Babel did not make any difference.
Ok, got it! Although I don´t know exactly what produced the error, I could solve the issue by creating a new meteor project with the --bare flag (so now I know that all npm dependencies are installed correctly to ensure that I can use 'import') and copied my code into the project. However, than I got another error message which told me that my bootstrap is not compatible with my jquery version. Before solving this, I had to delete codemirror in my client/vendor folder, which produces another error
Uncaught Error: Cannot find module ‘…/…/lib/codemirror’
Than I installed jquery#2.2.4 plus all required datatable npm dependencies I use in my code to keep the compatibility of my applied bootstrap and jquery. Now I can use import SimpleSchema from 'simpl-schema' and all other imports and no more errors occure.
So lastly, some npm and/or packages were wrong and the initial error could be solved by creating a new meteor project. The other errors were related to bootstrap/jquery compatibility and codemirror.
Related
Default install of NextJS 13 (13.0.7) "app" method doesn't work
I'm trying to create a brand new project using NextJS 13 to try out the new "app" folder approach. I use the following commands. npx create-next-app#latest --experimental-app npm run dev With no other changes whatsoever, I get the error below shown in the browser when I try to browse to localhost:3000. Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'call') Call Stack options.factory file:///D:/Projects/Personal/leeconlin-website/.next/static/chunks/webpack.js (710:31) __webpack_require__ /_next/static/chunks/webpack.js (37:33) fn file:///D:/Projects/Personal/leeconlin-website/.next/static/chunks/webpack.js (365:21) require node_modules\next\dist\client\image.js (7:15) ./node_modules/next/dist/client/image.js file:///D:/Projects/Personal/leeconlin-website/.next/static/chunks/app/page.js (39:1) options.factory /_next/static/chunks/webpack.js (710:31) __webpack_require__ file:///D:/Projects/Personal/leeconlin-website/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (365:21) __webpack_require__ node_modules\next\dist\client\app-index.js (26:16) requireModule node_modules\next\dist\compiled\react-server-dom-webpack\client.js (142:0) initializeModuleChunk node_modules\next\dist\compiled\react-server-dom-webpack\client.js (427:0) readChunk node_modules\next\dist\compiled\react-server-dom-webpack\client.js (252:0) mountLazyComponent node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (23079:0) beginWork node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (24792:0) beginWork$1 node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (32185:0) performUnitOfWork node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (31082:0) workLoopConcurrent node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (31068:0) renderRootConcurrent node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (31026:0) performConcurrentWorkOnRoot node_modules\next\dist\compiled\react-dom\cjs\react-dom.development.js (29983:0) workLoop node_modules\next\dist\compiled\scheduler\index.js (10:3921) flushWork node_modules\next\dist\compiled\scheduler\index.js (10:3629) MessagePort.performWorkUntilDeadline node_modules\next\dist\compiled\scheduler\index.js (10:1811) What am I missing?
The current solution is to use next.js 13.0.6, cause there's something wrong with 13.0.7. "dependencies": { "#next/font": "13.0.6", "#types/node": "18.11.17", "#types/react": "18.0.26", "#types/react-dom": "18.0.9", "eslint": "8.30.0", "eslint-config-next": "13.0.6", "next": "13.0.6", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "4.9.4" } if you still have an error, please delete your .next folder and node_modules folder, run npm i and try again. I found the solution here: TypeError: Cannot read properties of undefined (reading 'call') on Next.js
react-native-neomorph-shadows : Error in iphone 12
Hi I am facing issue with react-native-neomorph-shadows library. App crashes immediately after build being successful. I am not sure what is the issue. macOS version: 11.2.3 Edit-1 Package.json dependency: "#react-native-community/art": "^1.2.0", "#react-native-community/masked-view": "^0.1.11", "#react-navigation/bottom-tabs": "^5.11.13", "#react-navigation/native": "^5.9.4", "#react-navigation/stack": "^5.14.5", "react": "17.0.1", "react-native": "0.64.2", "react-native-gesture-handler": "^1.10.3", "react-native-linear-gradient": "^2.5.6", "react-native-neomorph-shadows": "^1.0.0", "react-native-reanimated": "^2.2.0", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.4.0" Error: error: Error: Unable to resolve module ./src/ShadowFlex from /Users/manikanttiwari/Desktop/test/app/node_modules/react-native-neomorph-shadows/index.js
Hi I was able to solve this problem. Please do npm i https://github.com/react-native-art/art.git instead of react-native link #react-native-community/art. This will solve the problem.
error navigator is not defined in node modules
I ran. while using Next.js. npm run dev (next dev) And get this error. ReferenceError: navigator is not defined at getChromeVersion (D:\zummon\page\node_modules\jest-worker\node_modules\supports-color\browser.js:5:68) at Object.<anonymous> (D:\zummon\page\node_modules\jest-worker\node_modules\supports-color\browser.js:14:22) at Module._compile (internal/modules/cjs/loader.js:1144:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10) at Module.load (internal/modules/cjs/loader.js:993:32) at Function.Module._load (internal/modules/cjs/loader.js:892:14) at Module.require (internal/modules/cjs/loader.js:1033:19) at require (internal/modules/cjs/helpers.js:72:18) at _supportsColor (D:\zummon\page\node_modules\jest-worker\build\workers\ChildProcessWorker.js:39:16) at ChildProcessWorker.initialize (D:\zummon\page\node_modules\jest-worker\build\workers\ChildProcessWorker.js:136:24) code in package.json { "dependencies": { "#heroicons/react": "^1.0.1", "#tailwindcss/forms": "^0.3.3", "#tailwindcss/typography": "^0.4.1", "gray-matter": "^4.0.3", "next": "^10.2.3", "next-mdx-remote": "^3.0.2", "react": "^17.0.2", "react-dom": "^17.0.2" }, "devDependencies": { "#types/react": "^17.0.11", "autoprefixer": "^10.2.6", "postcss": "^8.3.5", "tailwindcss": "^2.2.2", "typescript": "^4.3.4" } } I also downloaded new version for node.js (v13.6.0) before this happened, if this in case. I now can't see my editing work, please. I wanna know how to fix this situation.
I found the same problem with node.js version 13.6.0. I changed to 14.17.0 and the problem is fixed as well.
Android firestore could not reach backend error in react native
I have been looking for the solution about this issue, but I couldn't find it until now. It is such a weird issue. I tried with react-native 0.56.0 at first, it compiles well, and then this error is occured on the android device. firestore(5.5.0) could not reach backend However, the problem is that the error doesn't happen to android simulator. It only happens to android device. (It's really weird) So, I tried with react-native 0.57.1 in this time, then this error occured. And it's printed that The development server returned response error code: 500 on android device screen. error: bundling failed: Error: Unable to resolve module schedule/tracking from /Users/jeonmingyu/work/foodup-mobile-RN/node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js: Module schedule/tracking does not exist in the Haste module map This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following: 1. Clear watchman watches: watchman watch-del-all. 2. Delete the node_modules folder: rm -rf node_modules && npm install. 3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache. 4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*. at ModuleResolver.resolveDependency (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:1301) at ResolutionRequest.resolveDependency (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:83:16) at DependencyGraph.resolveDependency (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/node-haste/DependencyGraph.js:238:485) at Object.resolve (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/lib/transformHelpers.js:180:25) at dependencies.map.result (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/DeltaBundler/traverseDependencies.js:311:29) at Array.map () at resolveDependencies (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/DeltaBundler/traverseDependencies.js:307:16) at /Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/DeltaBundler/traverseDependencies.js:164:33 at Generator.next () at step (/Users/jeonmingyu/work/foodup-mobile-RN/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:307) Here's my package.json package.json "dependencies": { "#firebase/firestore": "^0.8.1", "firebase": "^5.5.1", "immutable": "^3.8.2", "loaders.css": "^0.1.2", "lodash": "^4.17.10", "moment": "^2.22.2", "native-base": "^2.7.2", "react": "16.3.1", "react-geocode": "^0.1.2", "react-loaders": "^3.0.1", "react-native": "^0.57.0", "react-native-app-intro-slider": "^0.2.4", "react-native-fast-image": "^4.0.14", "react-native-loader": "^1.2.1", "react-native-maps": "^0.21.0", "react-native-phone-call": "^1.0.7", "react-native-side-menu": "^1.1.3", "react-native-swiper": "^1.5.13", "react-navigation": "^2.3.1", "react-redux": "^5.0.7", "react-redux-firebase": "^2.1.6", "redux": "^4.0.0", "redux-actions": "^2.4.0", "redux-devtools-extension": "^2.13.5", "redux-firestore": "^0.5.7", "redux-persist": "^5.10.0", "redux-thunk": "^2.3.0", "remote-redux-devtools": "^0.5.13" }, "devDependencies": { "babel-jest": "23.0.1", "babel-preset-react-native": "^5.0.2", "jest": "23.1.0", "lint-staged": "^7.2.2", "node-sass": "^4.9.2", "react-native-sass-transformer": "^1.2.2", "react-test-renderer": "16.3.1", "redux-devtools-extension": "^2.13.5" } If anyone knows about it and has solution, please share your solution. It drives me crazy! :(
"No resource found that matches the given name" when I gradlew assembleDebug
I've cloned the react-native-hackathon-starter repo, wrote my own little app and tried to build an apk for debug using gradle assembleDebug, but I get this exception: path\to\project\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\10.2.1\res\drawable\common_google_signin_btn_icon_dark_normal.xml:3:29-91 : No resource found that matches the given name (at 'drawable' with value '#drawable/common_google_signin_btn_icon_dark_normal_background'). path\to\project\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\10.2.1\res\drawable\common_google_signin_btn_icon_light_normal.xml:3:29-92 : No resource found that matches the given name (at 'drawable' with value '#drawable/common_google_signin_btn_icon_light_normal_background'). path\to\project\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\10.2.1\res\drawable\common_google_signin_btn_text_dark_normal.xml:3:29-91 : No resource found that matches the given name (at 'drawable' with value '#drawable/common_google_signin_btn_text_dark_normal_background'). path\to\project\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\10.2.1\res\drawable\common_google_signin_btn_text_light_normal.xml:3:29-92 : No resource found that matches the given name (at 'drawable' with value '#drawable/common_google_signin_btn_text_light_normal_background'). FAILED FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':react-native-firestack:processReleaseResources'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\my_user\AppData\Local\Android\android-sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1 Try: Run with --info or --debug option to get more log output. Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-firestack:processReleaseResources'. From what I can tell, it's missing some graphical resources. I've tried gradlew clean before assemble, it still doesn't fix the issue. Someone else has the same issue as me. My package.json: { "name": "HackathonStarter", "version": "0.0.2", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "firebase": "^3.6.7", "native-base": "^2.1.0", "react-addons-update": "^15.4.2", "react-native-easy-grid": "^0.1.8", "react-native-firestack": "^2.3.9", "react-native-router-flux": "^3.37.0", "react-native-svg": "^5.1.7", "redux-thunk": "^2.2.0", "jest-react-native": "^18.0.0", "lodash": "^4.17.4", "react": "~15.5.4", "react-native": "0.43.4", "react-native-elements": "^0.11.2", "react-native-vector-icons": "^4.0.0", "react-redux": "^5.0.1", "redux": "^3.6.0" }, "devDependencies": { "babel-jest": "19.0.0", "babel-preset-react-native": "1.9.1", "jest": "19.0.2", "react-test-renderer": "~15.5.4" }, "jest": { "preset": "react-native" } } Does anyone have any idea how to fix this?
After deleting the node_modules folder, doing another npm install, removing node_modules/react-native-router-flux/react-native and editing out compile 'com.google.android.gms:play-services-base:+ from node_modules/react-native-firestack/android/build.gradle, because it was causing interference with the gms dependency in my root build.gradle, I was able to do a gradlew assembleDebug and assembleRelease. I think there was a problem with the firestack package, not bundling assets together correctly or whatever. All good now.