I created a small test app using
vue-diagram-editor
from https://github.com/max-kut/vue-diagram-editor.
That worked no problem so wanted to install it into my main vue app, which was running fine beforehand.
$ npm install --save vue-diagram-editor ... ok installed.
$ npm run serve
INFO Starting development server...
98% after emitting CopyPlugin
ERROR Failed to compile with 2 errors 08:10:04
error in ./src/views/InstructorReadings.vue?vue&type=script&lang=js&
Syntax Error: Unexpected token (95:34)
93 | for (var i2 = 0; i2 < AllRTEvents[i].length; i2++) {
94 | var obj = {
> 95 | CreatedAt: AllRTEvents[i].[i2].createdAt,
| ^
96 | Comments: AllRTEvents[i].[i2].eventComments,
97 | PageNumber: AllRTEvents[i].[i2].eventPage.page_number,
98 | PageTitle: AllRTEvents[i].[i2].eventPage.page_title,
# ./src/views/InstructorReadings.vue?vue&type=script&lang=js& 1:0-287 1:303-306 1:308-592 1:308-592
# ./src/views/InstructorReadings.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://192.168.0.120:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
error in ./src/views/Reading.vue?vue&type=script&lang=js&
Syntax Error: Unexpected token (84:34)
82 | for (var i2 = 0; i2 < AllRTEvents[i].length; i2++) {
83 | var obj = {
> 84 | CreatedAt: AllRTEvents[i].[i2].createdAt,
| ^
85 | Comments: AllRTEvents[i].[i2].eventComments,
86 | PageNumber: AllRTEvents[i].[i2].eventPage.page_number,
87 | PageTitle: AllRTEvents[i].[i2].eventPage.page_title,
# ./src/views/Reading.vue?vue&type=script&lang=js& 1:0-276 1:292-295 1:297-570 1:297-570
# ./src/views/Reading.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://192.168.0.120:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
package.json
{
"name": "blah",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#aws-amplify/ui-vue": "^1.0.13",
"#tinymce/tinymce-vue": "^3.2.8",
"aws-amplify": "^3.4.3",
"core-js": "^3.6.5",
"moment": "^2.29.1",
"nanoid": "^3.1.23",
"vue": "^2.6.11",
"vue-diagram-editor": "^1.2.1",
"vue-router": "^3.2.0",
"vuetify": "^2.4.0",
"vuex": "^3.4.0",
"vuex-persistedstate": "^3.2.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "~2.4.1",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.0"
}
}
Tried npm update and npm update -g
After looking around I found it may be worth modifying vue.config.js but no didnt fix.
vue.config.js
module.exports = {
transpileDependencies: ["vuetify", "vue-diagram-editor"],
};
Any ideas wha has happened and how to resolve?
Thanks
As mentioned in the comment the problem is that the access should not be done by path / dot syntax.
Changing
AllRTEvents[i].[i2].createdAt
To
AllRTEvents[i][i2].createdAt
Will fix the problem (if also done for all subsequent accesses).
Related
I'm trying to add authentication and password hashing to a Vue application. I'm able to install bcrypt with no issues, but when I require it in a file, it causes the entire app to crash. There are multiple errors inside a #mapbox node module folder, and a ton of basic node.js issues. Here is the first error:
ERROR in ./node_modules/#mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
It then has over 50 errors related to 'fs', 'util', 'path' like the one below
ERROR in ./node_modules/#mapbox/node-pre-gyp/lib/clean.js 10:15-35
Module not found: Error: Can't resolve 'fs' in '/Users/se/Documents/dev/lt/node_modules/#mapbox/node-pre-gyp/lib'
These fs, util, path, module not found errors appear are in a variety of different modules when importing/requiring bcrypt in a file.
Removing bcrypt from the top of my file (no longer requiring or importing it) fixes the issue and everything loads normally again.
I tried reading into webpack and bundlers and installed the latest version of webpack to no avail. I've also read online that it could be babel? so I installed and updated that package but also had no success. I'm scratching my head and I have no idea where to go or what to try at this point.
I'm wondering if there are incompatible packages or maybe I configured something wrong in my package.json so I've listed it here:
{
"name": "learn-together",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "node app.js && vue-cli-service serve",
"start:prod": "NODE_ENV=production nodemon app.js",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"server": "nodemon app.js",
"client": "vue-cli-service serve"
},
"dependencies": {
"#googlemaps/js-api-loader": "^1.14.3",
"#mapbox/node-pre-gyp": "^1.0.10",
"axios": "^0.27.2",
"babel-preset-es2015": "^6.24.1",
"bcrypt": "^5.1.0",
"body-parser": "^1.20.0",
"core-js": "^3.8.3",
"cors": "^2.8.5",
"dotenv": "^16.0.2",
"express": "^4.18.1",
"mongodb": "^4.10.0",
"mongoose": "^6.7.2",
"morgan": "^1.10.0",
"vue": "^3.2.13",
"vue-router": "^4.0.3",
"vue3-google-map": "^0.15.0",
"vuex": "^4.1.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-router": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"netlify-cli": "^12.0.2",
"nodemon": "^2.0.20",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0"
}
}
If anyone knows what this error could be or what I'm doing wrong would be great, many thanks
to explain my problem, I will start by saying that I am currently making a system in Vue with backend API Laravel (irrelevant). I am making them as 2 separate projects. My problem is in the frontend Vue part. I created it using Vue CLI.
Here is my package.json file:
"dependencies": {
"#popperjs/core": "^2.9.3",
"axios": "^0.21.1",
"bootstrap": "^5.1.0",
"core-js": "^3.6.5",
"dotenv": "^10.0.0",
"vue": "^3.0.0",
"vue-axios": "^3.2.5",
"vue-plugin-load-script": "^2.0.1",
"vue-router": "^4.0.11",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.0.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0",
"laravel-mix": "^6.0.31",
"prettier": "^2.2.1",
"resolve-url-loader": "^4.0.0",
"sass": "^1.38.1",
"sass-loader": "^12.1.0",
"webpack": "^5.52.1"
}
As you can see I am using laravel-mix (specifically to use the npm run dev command).
So to use laravel-mix I also needed to install webpack.
Now the problem arises at the point when I try to run npm run serve command to start the app. I get this error:
Error: module property was removed from Dependency (use compilation.moduleGraph.updateModule(dependency, module) instead)
And I have found 1 solution which was to use webpack 4 instead of 5, which kind of did not work, because when I use webpack 4 I can run "npm run serve" but when I run "npm run dev", it does not mix my assets. No error, only the command is parsed but nothing else.
I really did not find any solution, other than switch webpack version, however the asset mixing part is really cruical in the project.
Update 1:
Here is my webpack.mix.js
let mix = require("laravel-mix");
mix.sass('src/assets/sass/style.scss', 'src/assets/sass')
.styles([
'src/assets/template/css/datatables.min.css',
'src/assets/template/css/rowGroup.dataTables.min.css',
'src/assets/template/css/fullcalendar.min.css',
'src/assets/template/css/select2.min.css',
'src/assets/template/css/bootstrap-colorpicker.min.css',
'src/assets/template/css/bootstrap-datepicker.min.css',
'src/assets/template/css/bootstrap.min.css',
'src/assets/template/css/icons.min.css',
'src/assets/template/css/app.min.css',
'src/assets/sass/style.css'
], 'public/css/style.css')
.scripts([
'src/assets/template/js/jquery.min.js',
'src/assets/template/js/bootstrap.min.js',
'src/assets/template/js/metismenu.min.js',
'src/assets/template/js/simplebar.min.js',
'src/assets/template/js/node-waves.min.js',
'src/assets/template/js/waypoints.min.js',
'src/assets/template/js/jquery-counterup.min.js',
'src/assets/template/js/datatables.min.js',
'src/assets/template/js/dataTables.rowGroup.min.js',
'src/assets/template/js/moment.min.js',
'src/assets/template/js/jquery-ui-dist.min.js',
'src/assets/template/js/fullcalendar.min.js',
'src/assets/template/js/select2.min.js',
'src/assets/template/js/bootstrap-colorpicker.min.js',
'src/assets/template/js/bootstrap-datepicker.min.js',
'src/assets/template/js/apexcharts.min.js',
'src/assets/template/js/app.min.js',
'src/assets/js/script.js'
], 'public/js/script.js');
Could not resolve this problem, so instead I found a replacement for laravel-mix
I used gulp and created my own scripts for parsing sass and mixing css,js and minification.
https://gulpjs.com/
I am facing error while trying to start sub-app in Single-SPA application. Basically, I am trying to develop a kind of util app (sub app in Single-SPA) which contains Sockjs, Stomp-client etc. I have removed node modules and package-lock.json and installed node modules again. When I try to start application I am facing below error.
Error:
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'firewall'. These properties are valid:
object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? }
- options.client has an unknown property 'host'. These properties are valid:
object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
Command used for running the app : npm start
package.json
{
"name": "#sudeep/livedoc",
"scripts": {
"start": "webpack serve",
"start:standalone": "webpack serve --env standalone",
"build": "webpack --mode=production",
"analyze": "webpack --mode=production --env analyze",
"lint": "eslint src --ext js,ts,tsx",
"format": "prettier --write .",
"check-format": "prettier --check .",
"prepare": "husky install",
"test": "cross-env BABEL_ENV=test jest --passWithNoTests",
"watch-tests": "cross-env BABEL_ENV=test jest --watch",
"coverage": "cross-env BABEL_ENV=test jest --coverage"
},
"devDependencies": {
"#babel/core": "^7.14.6",
"#babel/eslint-parser": "^7.14.7",
"#babel/plugin-transform-runtime": "^7.14.5",
"#babel/preset-env": "^7.14.7",
"#babel/preset-typescript": "^7.14.5",
"#babel/runtime": "^7.14.6",
"babel-jest": "^27.0.5",
"concurrently": "^6.2.0",
"cross-env": "^7.0.3",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-ts-important-stuff": "^1.1.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.0.5",
"jest-cli": "^27.0.5",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"ts-config-single-spa": "^2.0.1",
"typescript": "^4.3.4",
"webpack": "^5.40.0",
"webpack-cli": "^4.7.2",
"webpack-config-single-spa": "^4.0.0",
"webpack-config-single-spa-ts": "^2.2.2",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.8.0"
},
"dependencies": {
"#types/jest": "^26.0.23",
"#types/systemjs": "^6.1.0",
"#types/webpack-env": "^1.16.0",
"fast-json-patch": "3.0.0-1",
"rxjs": "6.6.0",
"stompjs": "2.3.3",
"sockjs-client": "1.5.0"
}
}
I resolved this problem by updating "webpack-config-single-spa-ts" from 2.0.0 to 3.0.0.
The firewall option has been renamed as of webpack-dev-server v4.0.0-rc.0
You should use allowedHosts instead of firewall.
This problem has been fixed in version 4.0.0 of webpack-config-single-spa
, so upgrading this package will fix your issue as well.
I had the same situation in React.
The package.json file for the project had:
"webpack-config-single-spa-react": "2.0.0",
Therefore, when I executed
npm i
npm installed the exact required version of this component (2.0.0). It is possible to verify the installed version, if you look under
./node_modules/webpack-config-single-spa-react/package.json
I manually deleted the folder webpack-config-single-spa-react.
Edited the package.json in my project to request a version above 3.0.0:
"webpack-config-single-spa-react": "^3.0.0",
executed "npm install"
verified that at least version 3.0.0 of the package was installed by looking at:
./node_modules/webpack-config-single-spa-react/package.json
The actions above resolved the problem.
Modify in your package.json this module webpack-dev-server to 4.0.0-beta.0 and rebuild.
My versions:
packages
I am trying to install locally and globally a npm depency by using npm install -g ..
The package.json seems to be ok :
{
"private": true,
...
"main": "dist/main.js",
"bin": {
"gbts": "./dist/main.js"
},
"scripts": {
"build": "tsc"
},
...
"dependencies": {
"minimist": "^1.2.5",
"ora": "^5.1.0",
"ts2c": "^2.2.7",
"yargs": "^16.1.1"
},
"devDependencies": {
"#types/node": "^14.14.10",
"eslint": "6.8.0",
"install": "^0.13.0",
"npm": "^6.14.9",
"tslint": "^5.12.1",
"typescript": "^3.3.3"
}
}
This works perfetly, but when I invoke the command gbts, I still have this error pop in error on windows:
It occurs on the following line :
const parse = require("minimist");
I do not understand why this produce a syntax error, project's dependencies are missing?
Any solution in my case?
I get error when using react test utils. Following this blog post: http://blog.sodhanalibrary.com/2016/11/reacttestutils-tutorial-with-examples.html#.WoVNkqhl8dU . Can you advise what's wrong?
My test class:
import AzSearch from '../components/AzSearch'
import { render } from 'enzyme';
//import ReactTestUtils from 'react-dom/test-utils';
import TestUtils from 'react-addons-test-utils';
describe('AzSearch', () => {
it('should render wihtout problems', () => {
//define component
//var root = TestUtils.renderIntoDocument(<AzSearch />);
//Check it exists
//expect(root).toExist();
var shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(<AzSearch/>);
expect(shallowRenderer.getRenderOutput()).toExist();
});
});
My package:
{
"name": "npmsharepoint",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"build": "browserify -t [ babelify --presets [ react ] ] src/app/scripts/main.js -o src/scripts/app.js",
"clean": "gulp clean",
"test": "mocha src/webparts/User Web Parts/src/webparts/azSearch/tests/AzSearch.test.js --require src/webparts/User Web Parts/src/webparts/azSearch/tests/testHelpers.js --require src/webparts/User Web Parts/src/webparts/azSearch/tests/dom.js --recursive"
},
"dependencies": {
"#microsoft/sp-core-library": "~1.1.0",
"#microsoft/sp-lodash-subset": "~1.1.0",
"#microsoft/sp-office-ui-fabric-core": "~1.4.0-0",
"#microsoft/sp-webpart-base": "~1.1.0",
"#types/jquery": "^2.0.48",
"#types/jqueryui": "https://registry.npmjs.org/#types/jqueryui/-/jqueryui-1.11.37.tgz",
"#types/react": "0.14.46",
"#types/react-addons-shallow-compare": "0.14.17",
"#types/react-addons-test-utils": "0.14.15",
"#types/react-addons-update": "0.14.14",
"#types/react-dom": "0.14.18",
"#types/webpack-env": ">=1.12.1 <1.14.0",
"babel-preset-react": "^6.24.1",
"babelify": "^8.0.0",
"bootstrap": "^4.0.0-beta.2",
"browser-router": "^0.2.0",
"jquery": "^2.2.4",
"jqueryui": "https://registry.npmjs.org/jqueryui/-/jqueryui-1.11.1.tgz",
"prop-types": "^15.6.0",
"react": "15.4.2",
"react-autosuggest": "^9.3.2",
"react-bootstrap": "^0.31.5",
"react-bootstrap-table": "^4.3.1",
"react-dom": "15.4.2",
"react-responsive-modal": "^2.0.0",
"react-select": "^1.1.0",
"reactstrap": "^5.0.0-alpha.4",
"sp-pnp-js": "^3.0.3"
},
"devDependencies": {
"#microsoft/sp-build-web": "~1.1.0",
"#microsoft/sp-module-interfaces": "~1.1.0",
"#microsoft/sp-webpart-workbench": "~1.1.0",
"#types/chai": ">=3.4.34 <3.6.0",
"#types/material-ui": "^0.20.0",
"#types/mocha": ">=2.2.33 <2.6.0",
"#types/react-tap-event-plugin": "0.0.30",
"ajv": "~5.2.2",
"gulp": "~3.9.1",
"chai": ">=3.4.34 <3.6.0",
"mocha": ">=2.2.33 <2.6.0"
}
}
Error:
Module parse failed: C:\Users/React Projects/Web Parts/b2\SPWPTest\src\webparts\User Web Parts\lib\webparts\azSearch\tests\AzSearch.test.js Unexpected token (33:25)
You may need an appropriate loader to handle this file type.
|
| var shallowRenderer = TestUtils.createRenderer();
| shallowRenderer.render(<AzSearch/>);
| expect(shallowRenderer.getRenderOutput()).toExist();
| });
at C:/Users/React Projects/Web Parts/b2/SPWPTest/src/webparts/User Web Parts/temp/tests.js:109
Finished in 0.249 secs / 0 secs
SUMMARY:
√ 0 tests completed
15 02 2018 09:39:27.572:DEBUG [karma]: Run complete, exiting.
15 02 2018 09:39:27.573:DEBUG [launcher]: Disconnecting all browsers
Finished in 0.249 secs / 0 secs
SUMMARY:
√ 0 tests completed
15 02 2018 09:39:27.589:DEBUG [karma]: Run complete, exiting.
15 02 2018 09:39:27.590:DEBUG [launcher]: Disconnecting all browsers
Am I missing some import or module or running incorrect version of something?
Your are missing compilers config at mocha.
The possible missing part is:
--compilers js:babel-core/register
See this link.