Hi all.. I am trying to use moment timezone libra...
# suitescript
m
Hi all.. I am trying to use moment timezone library file in script 2.0 but its giving error as "Module does not exist : /moment.js" But same i am using in script 1.0 It is working. Any suggetion?
s
double check your path, try putting a period at start of path like
./moment
s
Make sure you are using a recent enough version of moment. For suitescript 1.0, old versions of moment worked because it was provided through a global object. They recommend version 2.14 or later when using moment with Require (as an AMD module): https://momentjs.com/docs/#/use-it/require-js/
m
But file name with path is completely different. Not understanding why such error is getting
s
you should be using something like:
./moment-timezone-with-data
based on the filename in your second screenshot
you have to specify your module by their actual path and file name, leaving the
.js
off of the end
m
@scottvonduhn
s
see the above note. you need to remove the .js from the end of your require strings
m
Ok let me try.
b
you should be starting at the source of moment timezone to debug
Copy code
if (typeof module === 'object' && module.exports) {
		module.exports = factory(require('moment')); // Node
	} else if (typeof define === 'function' && define.amd) {
		define(['moment'], factory);                 // AMD
	} else {
		factory(root.moment);                        // Browser
	}
s
also, there should be no leading / before SuiteScripts
b
moment timezone required a module with the moment id to exist
you will need to use a require Configuration for that
m
@scottvonduhn i have removed .js from the end and also removed leading / . But giving same error..
@battk let me try solution that u provided..
s
@battk makes a good point. When you include a module that has other dependencies, you need to make sure they can be loaded as-is, either by relative location, or by using an AMD configuration file
moment.js, by itself, has no dependencies, but the timezone module does, and it is almost certainly causing your errors.