Comments (25)
I have in /config/config.json: "localizedResources": {
"HelloReactCompWebPartStrings": "webparts/helloReactComp/loc/{locale}.js",
"ControlStrings": "./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
}
and a file "\lib\webparts\helloReactComp\loc\en-us.js"
the "npm install @pnp/spfx-controls-react --save --save-exact" installed a folder:
"E:\Learning\SPFrameWork\WithReact\react-Comp\node_modules@pnp\spfx-controls-react\lib\loc" with en-us.js en-us.d.ts and en-us.js.map
I also get the error:
"Error for resource "ControlStrings": No localized files found under the "lib" directory matching pattern "./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js""
I changed the config.json to be:
"ControlStrings": "../node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
because the file is under config folder, it should go up twice to get down to node_modules.
You should change the documentation
from sp-dev-fx-controls-react.
@estruyf
Yes that notation is also working. It probably goes looking for the module folder ?
Thx.
from sp-dev-fx-controls-react.
Some of our controls make use of a resource file which you need to add to your config.json file. This step is explained in the getting started guide: https://sharepoint.github.io/sp-dev-fx-controls-react/getting-started/
Did you add this in your project?
from sp-dev-fx-controls-react.
Yes, I added "ControlStrings": "./node_modules/@pnp/lib/loc/{locale}.js" to config.json.
Without it I had different error.
Now I have workaround by copying resource file to webpart folder and point to a new path.
Everything works fine in this configuration.
I think it can be some folder permissions issue, but everyting else works just fine...
from sp-dev-fx-controls-react.
Did you use this path ./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js
instead of "./node_modules//loc/{locale}.js"
?
from sp-dev-fx-controls-react.
Yes, sorry, it was a strange typo while I copy my error.
There is a right one:
"Error for resource "ControlStrings": No localized files found under the "lib" directory matching pattern "./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js""
I had copy of path from "getting started" page, and have this issue with it.
When I use path to my webparts folder - it works just fine.
from sp-dev-fx-controls-react.
Can you check if the path is correct on your machine? Does the file exists in the node_modules folder structure?
from sp-dev-fx-controls-react.
I checked it, it's correct (except it's en-us instead of {locale}).
There is a screenshot of my config file with opened path to file in VSCode:
from sp-dev-fx-controls-react.
The location is good, it needs to include the locale token. Might be a stupid question, but is the file saved?
from sp-dev-fx-controls-react.
Yes, file is saved. I know, on screenshot its not saved, but I saved it several times, changing from this location to webparts copy locations. And error mention to this location. So I think my problems can be in some permission issue when gulp process can't read this location, but I can't figure what can be wrong and why everything else (webpack compliling, for instance) working.
from sp-dev-fx-controls-react.
Do you also have it when you start with a new project?
from sp-dev-fx-controls-react.
It was quite a new project. But I will try to create another one just to reproduce this issue.
I will keep you informed.
I'm afraid I will do it only at Monday, so it will be some delay from my side.
from sp-dev-fx-controls-react.
No problem.
from sp-dev-fx-controls-react.
Sorry for delay.
Now I'm test it with newly created empty project.
Just created spfx project, did npm install @pnp/spfx-controls-react --save --save-exact
, add ControlsStrings to config.json.
After adding ControlsString I'm start to receive error message while doing gulp serve.
I'm on Windows 2016 Server.
[10:56:03] Project spfx-test version: 0.0.1
[10:56:03] Build tools version: 2.5.3
[10:56:03] Node version: v7.10.0
from sp-dev-fx-controls-react.
I tested this out on a couple Windows environments, but I do not encounter the issue. Even tested it with Node v8.
It might not make any difference, but have you tested it out on a none server version already?
from sp-dev-fx-controls-react.
Thank @Ofer-Gal, but I did some tests, and by actually using ../node_modules
I get that error you are mentioning. Everything in the config.json
file is mapped to ./
like, for instance, the entrypoint and manifest location of your web part:
Can you try out to including this:
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
from sp-dev-fx-controls-react.
I tested this one out on a couple of other environments, and changing it to ../node_modules
leads to the mentioned error:
[10:34:07] Error - 'collectLocalizedResources' sub task errored after 11 ms
Error for resource "ControlStrings": No localized files found under the root directory ("C:\data\pnp-controls") matching pattern "../node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
Like mentioned in my previous reply, the following path might work (or at least it does in the environments where I tested it - MacOS and Windows):
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
If you can let me know the results of your tests, that would be great.
from sp-dev-fx-controls-react.
Hello,
I also had this issue and the reason why it fails in my case is:
The path to the localized resource file, relative to the root of the project
When you use the ../.. notation inside the reference of the controlstrings, it is going to be based on the current location.
What does that mean? If you need to go 5 folders up to reach the modules from the current folder
you would type ../../ and so on. But if you hover over the "ControlStrings" it says
The path to the localized resource file, relative to the root of the project. Which means that when trying to look for that file it will start at the root. So you do not need to go up 5 times. But start at the root and than look how many more you need to go up.
This scenario is only correct if your modules are not inside each and every extension.
Hope this makes sense
Kind regards
Simon
from sp-dev-fx-controls-react.
@Simo9552 thanks for your comment. The config.json file paths are a bit special. As the paths are processed in the build process and seem to be giving problems with relative paths. Have you tried out this notation "ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
?
from sp-dev-fx-controls-react.
Thanks @Simo9552 for testing. The config.json
is indeed used during the build from a different location. That is why the mismatch can occur.
Documentation got updated. Closing this issue as it is now solved.
from sp-dev-fx-controls-react.
@estruyf thanks for your time helping out @Simo9552 – I had a similar issue resolved from your feedback.
Thank you sir!
from sp-dev-fx-controls-react.
I have in /config/config.json: "localizedResources": {
"HelloReactCompWebPartStrings": "webparts/helloReactComp/loc/{locale}.js",
"ControlStrings": "./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
}
and a file "\lib\webparts\helloReactComp\loc\en-us.js"
the "npm install @pnp/spfx-controls-react --save --save-exact" installed a folder:
"E:\Learning\SPFrameWork\WithReact\react-Comp\node_modules@pnp\spfx-controls-react\lib\loc" with en-us.js en-us.d.ts and en-us.js.map
I also get the error:
"Error for resource "ControlStrings": No localized files found under the "lib" directory matching pattern "./node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js""
I changed the config.json to be:
"ControlStrings": "../node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
because the file is under config folder, it should go up twice to get down to node_modules.
You should change the documentation
This path fix is what worked for me.
The ControlStrings value was initially set to "ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
after adding the package to my solution as Elio had suggested in his response (and the documentation). Could this have something to do with the v1 schema (in older spfx solutions) on the config.json file?
Using [email protected] with [email protected]
from sp-dev-fx-controls-react.
Changing from "ControlStrings": "/node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js" to "ControlStrings": "../node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js" worked for me.
Thanks @Ofer-Gal
from sp-dev-fx-controls-react.
@estruyf Thanks, this helped!
from sp-dev-fx-controls-react.
@estruyf This worked for me too. The docs are incorrect. I used ../
at the start of the string and it worked. Update - docs have been updated??
from sp-dev-fx-controls-react.
Related Issues (20)
- [Dynamic Field] Implement Radio Buttons for choice fields
- LivePersona does not show hover in Teams Mobile HOT 2
- Dynamic Form - enable/disable save button HOT 2
- Richtextbox editor control HOT 2
- Dynamic Forms /layouts/15 404 error HOT 1
- DragDropFiles issue in workbench (Object(...) is not a function)
- People Picker - "@pnp/spfx-controls-react/lib/PeoplePicker" has no exported member named 'IPeoplePickerContext' HOT 4
- Issue with PeopleSearchService and @pnp/spfx-controls-react/lib/PeoplePicker HOT 3
- RichText write words backwards HOT 1
- How to properly use the adaptive card designer control in spfx 1.16.1 HOT 1
- Dynamic Form - Lookup field limited to first 100 items HOT 2
- Pass Custom Element into Adaptive Card Designer Host
- iFrame Dialog and Panel Cross Domain and Sandbox questions HOT 1
- iFrame Panel Control causes page to scroll when it is closed
- iFrameDialog Control causes page to scroll to top automatically when dialog was closed HOT 1
- FileTypeIcon Errors Out and Crashes Page HOT 2
- FilePicker - OneDrive items sort by Modified HOT 1
- `UploadFiles`: Add Property limit the number of files that a user can upload
- Enhancement : ListItemComments Ability to Like/Unlike and to reply on comments HOT 1
- Dynamic Form - Saving not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sp-dev-fx-controls-react.